Here you can find the source of collectionToString(Collection> list)
public static String collectionToString(Collection<?> list)
//package com.java2s; //License from project: LGPL import java.util.*; public class Main { public static String collectionToString(Collection<?> list) { if (null == list) { return null; }/*from www . ja v a 2 s.c om*/ final StringBuilder sb = new StringBuilder(); for (final Object item : list) { if (null != item) { sb.append(item.toString()); } } return sb.toString(); } public static String toString(final Collection list) { final StringBuilder sb = new StringBuilder(); if (null != list) { for (final Object item : list) { if (null != item) { sb.append(item); } } } return sb.toString(); } public static String toString(final Object[] list) { final StringBuilder sb = new StringBuilder(); if (null != list) { for (final Object item : list) { if (null != item) { sb.append(item); } } } return sb.toString(); } }