Here you can find the source of arrayToString(Object[] arr)
public static String arrayToString(Object[] arr)
//package com.java2s; import java.util.Arrays; import java.util.Collection; import java.util.Iterator; public class Main { public static String arrayToString(Object[] arr) { return collectionToString(Arrays.asList(arr)); }/*from w ww . j a va2 s.c o m*/ public static String collectionToString(Collection c) { StringBuffer buff = new StringBuffer(); int i = 0; int size = c.size(); for (Iterator iter = c.iterator(); iter.hasNext();) { Object object = iter.next(); if (size > 1 && i == (size - 1)) { buff.append("and "); } buff.append(object); if (i < (size - 1)) { if (size > 2) { buff.append(", "); } else { buff.append(" "); } } i++; } return buff.toString(); } }