Here you can find the source of collectionToStr(Collection
public static <T> String collectionToStr(Collection<T> collection)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static <T> String collectionToStr(Collection<T> collection) { StringBuilder result = new StringBuilder(""); if (collection == null) { return result.toString(); }/*from w w w . j av a2 s . c o m*/ T[] array = (T[]) collection.toArray(); for (int i = 0; i < array.length; i++) { result.append(array[i]); if (i != array.length - 1) { result.append(","); } } return result.toString(); } }