Here you can find the source of arrayToString(Object[] array)
public static String arrayToString(Object[] array)
//package com.java2s; public class Main { /**/*from ww w . j av a 2 s .co m*/ * Returns a comma-delimited string representation of the specified array, with []s. */ public static String arrayToString(Object[] array) { return arrayToString(array, ", ", -1); } /** * Returns a delimited string representation of the specified array, with []s. * @param delim what delimiter to use in between array elements. */ public static String arrayToString(Object[] array, String delim) { return arrayToString(array, delim, -1); } /** * @param delim what delimiter to use in between array elements. * @param maxValues how many array elements to include. * When less than 0, all values are included. * If <code>maxValues</code> is greater than the number of elements in <code>array</code>, * then all elements are included. * If any elements are not included, <code>...</code> will be inserted after the last element. */ public static String arrayToString(Object[] array, String delim, int maxValues) { if (delim == null) throw new IllegalArgumentException(); if (array == null) return null; if (array.length == 0) return ""; int max = maxValues < 0 ? array.length : Math.min(array.length, maxValues); StringBuffer temp = new StringBuffer(2 + (max * 16)); for (int i = 0; i < max; i++) { if (i > 0) temp.append(delim); temp.append(array[i]); } if (max < array.length) temp.append("..."); return temp.toString(); } }