Here you can find the source of arrayToString(Object array)
public static String arrayToString(Object array)
//package com.java2s; //License from project: Apache License public class Main { public static String arrayToString(Object array) { if (array instanceof byte[]) return arrayToString((byte[]) array); if (array instanceof short[]) return arrayToString((short[]) array); if (array instanceof int[]) return arrayToString((int[]) array); if (array instanceof long[]) return arrayToString((long[]) array); if (array instanceof float[]) return arrayToString((float[]) array); if (array instanceof double[]) return arrayToString((double[]) array); if (array instanceof boolean[]) return arrayToString((boolean[]) array); if (array instanceof char[]) return arrayToString((char[]) array); return arrayToString((Object[]) array); }/* w ww . j a v a2 s . c o m*/ private static String arrayToString(Object[] o) { StringBuilder sb = new StringBuilder(); String comma = ", "; String empty = ""; sb.append("["); for (int i = 0; i < o.length; i++) sb.append(i > 0 ? comma : empty).append(String.valueOf(o[i])); sb.append("]"); return sb.toString(); } private static String arrayToString(byte[] o) { StringBuilder sb = new StringBuilder(); String comma = ", "; String empty = ""; sb.append("["); for (int i = 0; i < o.length; i++) sb.append(i > 0 ? comma : empty).append(String.valueOf(o[i])); sb.append("]"); return sb.toString(); } private static String arrayToString(short[] o) { StringBuilder sb = new StringBuilder(); String comma = ", "; String empty = ""; sb.append("["); for (int i = 0; i < o.length; i++) sb.append(i > 0 ? comma : empty).append(String.valueOf(o[i])); sb.append("]"); return sb.toString(); } private static String arrayToString(int[] o) { StringBuilder sb = new StringBuilder(); String comma = ", "; String empty = ""; sb.append("["); for (int i = 0; i < o.length; i++) sb.append(i > 0 ? comma : empty).append(String.valueOf(o[i])); sb.append("]"); return sb.toString(); } private static String arrayToString(long[] o) { StringBuilder sb = new StringBuilder(); String comma = ", "; String empty = ""; sb.append("["); for (int i = 0; i < o.length; i++) sb.append(i > 0 ? comma : empty).append(String.valueOf(o[i])); sb.append("]"); return sb.toString(); } private static String arrayToString(float[] o) { StringBuilder sb = new StringBuilder(); String comma = ", "; String empty = ""; sb.append("["); for (int i = 0; i < o.length; i++) sb.append(i > 0 ? comma : empty).append(String.valueOf(o[i])); sb.append("]"); return sb.toString(); } private static String arrayToString(double[] o) { StringBuilder sb = new StringBuilder(); String comma = ", "; String empty = ""; sb.append("["); for (int i = 0; i < o.length; i++) sb.append(i > 0 ? comma : empty).append(String.valueOf(o[i])); sb.append("]"); return sb.toString(); } private static String arrayToString(boolean[] o) { StringBuilder sb = new StringBuilder(); String comma = ", "; String empty = ""; sb.append("["); for (int i = 0; i < o.length; i++) sb.append(i > 0 ? comma : empty).append(String.valueOf(o[i])); sb.append("]"); return sb.toString(); } private static String arrayToString(char[] o) { StringBuilder sb = new StringBuilder(); String comma = ", "; String empty = ""; sb.append("["); for (int i = 0; i < o.length; i++) sb.append(i > 0 ? comma : empty).append(String.valueOf(o[i])); sb.append("]"); return sb.toString(); } }