Here you can find the source of arrayToString(final T[] array)
public static <T> String arrayToString(final T[] array)
//package com.java2s; //License from project: Open Source License import java.io.StringWriter; import java.util.Arrays; import java.util.Collection; import java.util.Iterator; public class Main { private static final String DEFAULT_LIST_SEPARATOR = ", "; public static <T> String arrayToString(final T[] array) { return collectionToString(Arrays.asList(array), DEFAULT_LIST_SEPARATOR); }/* w w w. j a v a 2 s . c o m*/ public static <T> String arrayToString(final T[] array, final String separator) { return collectionToString(Arrays.asList(array), separator); } public static String collectionToString(final Collection<?> coll) { return collectionToString(coll, DEFAULT_LIST_SEPARATOR); } public static String collectionToString(final Collection<?> coll, final String separator) { StringWriter sw = new StringWriter(); Iterator<?> it = coll.iterator(); boolean first = true; while (it.hasNext()) { if (first) { first = false; } else { sw.append(separator); } Object obj = it.next(); sw.append(obj == null ? "null" : obj.toString()); } return sw.toString(); } }