Here you can find the source of toString(Object array)
public static String toString(Object array)
//package com.java2s; import java.util.Arrays; public class Main { public static String toString(Object array) { if (array == null) { return null; }//from w ww. j a v a 2s . c o m Class<?> type = array.getClass(); if (type.isArray()) { if (type.getComponentType().isPrimitive()) { if (type == byte[].class) { byte[] valueArray = (byte[]) array; // using default encoding return new String(valueArray, 0, valueArray.length); } if (type == char[].class) { char[] charArray = (char[]) array; return new String(charArray); } if (type == short[].class) { return Arrays.toString((short[]) array); } if (type == int[].class) { return Arrays.toString((int[]) array); } if (type == long[].class) { return Arrays.toString((long[]) array); } if (type == float[].class) { return Arrays.toString((float[]) array); } if (type == double[].class) { return Arrays.toString((double[]) array); } if (type == boolean[].class) { return Arrays.toString((boolean[]) array); } } else { return Arrays.toString((Object[]) array); } } return array.toString(); } }