Here you can find the source of collectionToString(Collection col)
public static String collectionToString(Collection col)
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.Iterator; public class Main { /**/* w w w. jav a2 s .c om*/ * Prints each object in the collection with commas between them. * Nulls will print as "null". A null collection will cause NPE. */ public static String collectionToString(Collection col) { StringBuffer outputString = new StringBuffer(100); boolean firstItem = true; Iterator it = col.iterator(); while (it.hasNext()) { if (!firstItem) outputString.append(", "); outputString.append(it.next()); firstItem = false; } return outputString.toString(); } }