### Question:
ArrayUtils { public static String primitiveOrStringArrayToString(Object o) { if (o instanceof byte[]) { return Arrays.toString((byte[]) o); } else if (o instanceof char[]) { return Arrays.toString((char[]) o); } else if (o instanceof boolean[]) { return Arrays.toString((boolean[]) o); } else if (o instanceof long[]) { return Arrays.toString((long[]) o); } else if (o instanceof double[]) { return Arrays.toString((double[]) o); } else if (o instanceof int[]) { return Arrays.toString((int[]) o); } else if (o instanceof short[]) { return Arrays.toString((short[]) o); } else if (o instanceof float[]) { return Arrays.toString((float[]) o); } else if (o instanceof String[]) { return Arrays.toString((String[]) o); } throw new IllegalArgumentException("Object must be a primitive array!"); } private  ArrayUtils(); static boolean isPrimitiveArray(Object o); static boolean isPrimitiveOrStringArray(Object o); static boolean isArray(Object o); static boolean arrayFriendlyEquals(Object o1, Object o2); static int arrayFriendlyHashCode(Object o); static String primitiveOrStringArrayToString(Object o); static boolean arrayFriendlyMapEquals(Map<String, T> map1, Map<String, T> map2);  }### Answer:
@Test public void shouldCorrectlyPrintPrimitiveArray() { assertEquals("[3, 4]", primitiveOrStringArrayToString(new byte[]{3, 4})); assertEquals("[x, y]", primitiveOrStringArrayToString(new char[]{'x', 'y'})); assertEquals("[true, false]", primitiveOrStringArrayToString(new boolean[]{true, false})); assertEquals("[3, 4]", primitiveOrStringArrayToString(new long[]{3, 4})); assertEquals("[3.0, 4.0]", primitiveOrStringArrayToString(new double[]{3, 4})); assertEquals("[3, 4]", primitiveOrStringArrayToString(new int[]{3, 4})); assertEquals("[3, 4]", primitiveOrStringArrayToString(new short[]{3, 4})); assertEquals("[3.0, 4.0]", primitiveOrStringArrayToString(new float[]{3, 4})); assertEquals("[3, 4]", primitiveOrStringArrayToString(new String[]{"3", "4"})); assertEquals("[]", primitiveOrStringArrayToString(new float[]{})); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionWhenPrintingNonPrimitiveArray() { primitiveOrStringArrayToString(new Object[]{"bla"}); }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionWhenPrintingNonArray() { primitiveOrStringArrayToString("bla"); }