Java tutorial
//package com.java2s; import java.util.*; public class Main { public static String toString(Collection coll) { return toString(coll, " "); } public static String toString(Collection coll, String sep) { if (coll == null) return null; StringBuilder sbuf = new StringBuilder(sep == "\n" ? sep : ""); for (Object o : coll) sbuf.append("" + o + sep); return sbuf.toString(); } }