Here you can find the source of toString(Collection extends Object> collection, String prefix, String suffix)
public static String toString(Collection<? extends Object> collection, String prefix, String suffix)
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.List; public class Main { public static String toString(Collection<? extends Object> collection, String prefix, String suffix) { StringBuilder sb = new StringBuilder(); for (Object line : collection) { sb.append(prefix);//from ww w . ja va 2 s . c om sb.append(line.toString()); sb.append(suffix); } return sb.toString(); } public static String toString(List<List<String>> collection, String betweenElements, String betweenRows) { StringBuilder sb = new StringBuilder(); for (List<String> row : collection) { sb.append(row.get(0)); sb.append(betweenElements); sb.append(row.get(1)); sb.append(betweenRows); } return sb.toString(); } }