Java tutorial
//package com.java2s; import java.util.Collection; public class Main { public static String toString(Collection<? extends Object> collection) { return toString(collection, "\r\n"); } public static String toString(Collection<? extends Object> collection, String separator) { StringBuilder sb = new StringBuilder(); for (Object obj : collection) { sb.append(obj).append(separator); } return sb.toString(); } }