Here you can find the source of arrayToString(Object obj)
public static String arrayToString(Object obj)
//package com.java2s; //License from project: Apache License import java.util.Arrays; public class Main { public static String arrayToString(Object obj) { if (null == obj) { return null; }/*ww w. ja v a2 s . co m*/ if (isArray(obj)) { try { return Arrays.deepToString((Object[]) obj); } catch (Exception e) { final String className = obj.getClass().getComponentType().getName(); switch (className) { case "long": return Arrays.toString((long[]) obj); case "int": return Arrays.toString((int[]) obj); case "short": return Arrays.toString((short[]) obj); case "char": return Arrays.toString((char[]) obj); case "byte": return Arrays.toString((byte[]) obj); case "boolean": return Arrays.toString((boolean[]) obj); case "float": return Arrays.toString((float[]) obj); case "double": return Arrays.toString((double[]) obj); default: throw new RuntimeException(e); } } } return obj.toString(); } private static boolean isArray(Object obj) { if (null == obj) { // throw new NullPointerException("Object check for isArray is null"); return false; } return obj.getClass().isArray(); } }