@Test public void testToString() throws Exception { Object arr; arr = new long[] { 1 }; assertEquals(Arrays.toString((long[]) arr), ArrayUtil.toString(arr)); arr = new int[] { 1 }; assertEquals(Arrays.toString((int[]) arr), ArrayUtil.toString(arr)); arr = new short[] { 1 }; assertEquals(Arrays.toString((short[]) arr), ArrayUtil.toString(arr)); arr = new char[] { 1 }; assertEquals(Arrays.toString((char[]) arr), ArrayUtil.toString(arr)); arr = new byte[] { 1 }; assertEquals(Arrays.toString((byte[]) arr), ArrayUtil.toString(arr)); arr = new boolean[] { true }; assertEquals(Arrays.toString((boolean[]) arr), ArrayUtil.toString(arr)); arr = new float[] { 1f }; assertEquals(Arrays.toString((float[]) arr), ArrayUtil.toString(arr)); arr = new double[] { 1d }; assertEquals(Arrays.toString((double[]) arr), ArrayUtil.toString(arr)); arr = new Object[] { "str" }; assertEquals(Arrays.toString((Object[]) arr), ArrayUtil.toString(arr)); assertEquals(Integer.valueOf(1).toString(), ArrayUtil.toString(1)); assertEquals("null", ArrayUtil.toString(null)); }
public static String toString(Object obj) { if (obj == null) { return "null"; } final Class<?> clazz = obj.getClass(); if (!clazz.isArray()) { return obj.toString(); } final Class<?> componentType = obj.getClass().getComponentType(); if (long.class.equals(componentType)) { return Arrays.toString((long[]) obj); } else if (int.class.equals(componentType)) { return Arrays.toString((int[]) obj); } else if (short.class.equals(componentType)) { return Arrays.toString((short[]) obj); } else if (char.class.equals(componentType)) { return Arrays.toString((char[]) obj); } else if (byte.class.equals(componentType)) { return Arrays.toString((byte[]) obj); } else if (boolean.class.equals(componentType)) { return Arrays.toString((boolean[]) obj); } else if (float.class.equals(componentType)) { return Arrays.toString((float[]) obj); } else if (double.class.equals(componentType)) { return Arrays.toString((double[]) obj); } else { return Arrays.toString((Object[]) obj); } }
ArrayUtil { public static String toString(Object obj) { if (obj == null) { return "null"; } final Class<?> clazz = obj.getClass(); if (!clazz.isArray()) { return obj.toString(); } final Class<?> componentType = obj.getClass().getComponentType(); if (long.class.equals(componentType)) { return Arrays.toString((long[]) obj); } else if (int.class.equals(componentType)) { return Arrays.toString((int[]) obj); } else if (short.class.equals(componentType)) { return Arrays.toString((short[]) obj); } else if (char.class.equals(componentType)) { return Arrays.toString((char[]) obj); } else if (byte.class.equals(componentType)) { return Arrays.toString((byte[]) obj); } else if (boolean.class.equals(componentType)) { return Arrays.toString((boolean[]) obj); } else if (float.class.equals(componentType)) { return Arrays.toString((float[]) obj); } else if (double.class.equals(componentType)) { return Arrays.toString((double[]) obj); } else { return Arrays.toString((Object[]) obj); } } }
ArrayUtil { public static String toString(Object obj) { if (obj == null) { return "null"; } final Class<?> clazz = obj.getClass(); if (!clazz.isArray()) { return obj.toString(); } final Class<?> componentType = obj.getClass().getComponentType(); if (long.class.equals(componentType)) { return Arrays.toString((long[]) obj); } else if (int.class.equals(componentType)) { return Arrays.toString((int[]) obj); } else if (short.class.equals(componentType)) { return Arrays.toString((short[]) obj); } else if (char.class.equals(componentType)) { return Arrays.toString((char[]) obj); } else if (byte.class.equals(componentType)) { return Arrays.toString((byte[]) obj); } else if (boolean.class.equals(componentType)) { return Arrays.toString((boolean[]) obj); } else if (float.class.equals(componentType)) { return Arrays.toString((float[]) obj); } else if (double.class.equals(componentType)) { return Arrays.toString((double[]) obj); } else { return Arrays.toString((Object[]) obj); } }  }
ArrayUtil { public static String toString(Object obj) { if (obj == null) { return "null"; } final Class<?> clazz = obj.getClass(); if (!clazz.isArray()) { return obj.toString(); } final Class<?> componentType = obj.getClass().getComponentType(); if (long.class.equals(componentType)) { return Arrays.toString((long[]) obj); } else if (int.class.equals(componentType)) { return Arrays.toString((int[]) obj); } else if (short.class.equals(componentType)) { return Arrays.toString((short[]) obj); } else if (char.class.equals(componentType)) { return Arrays.toString((char[]) obj); } else if (byte.class.equals(componentType)) { return Arrays.toString((byte[]) obj); } else if (boolean.class.equals(componentType)) { return Arrays.toString((boolean[]) obj); } else if (float.class.equals(componentType)) { return Arrays.toString((float[]) obj); } else if (double.class.equals(componentType)) { return Arrays.toString((double[]) obj); } else { return Arrays.toString((Object[]) obj); } }  static int hashCode(Object obj); static boolean equals(Object thisObj, Object thatObj); static String toString(Object obj); }
ArrayUtil { public static String toString(Object obj) { if (obj == null) { return "null"; } final Class<?> clazz = obj.getClass(); if (!clazz.isArray()) { return obj.toString(); } final Class<?> componentType = obj.getClass().getComponentType(); if (long.class.equals(componentType)) { return Arrays.toString((long[]) obj); } else if (int.class.equals(componentType)) { return Arrays.toString((int[]) obj); } else if (short.class.equals(componentType)) { return Arrays.toString((short[]) obj); } else if (char.class.equals(componentType)) { return Arrays.toString((char[]) obj); } else if (byte.class.equals(componentType)) { return Arrays.toString((byte[]) obj); } else if (boolean.class.equals(componentType)) { return Arrays.toString((boolean[]) obj); } else if (float.class.equals(componentType)) { return Arrays.toString((float[]) obj); } else if (double.class.equals(componentType)) { return Arrays.toString((double[]) obj); } else { return Arrays.toString((Object[]) obj); } }  static int hashCode(Object obj); static boolean equals(Object thisObj, Object thatObj); static String toString(Object obj);  }