Here you can find the source of listToString(List l)
public static String listToString(List l)
//package com.java2s; import java.util.*; public class Main { public static String listToString(List l) { return listToString(l, ", ", "(", ")"); }//from ww w.j ava 2 s.c o m public static String listToString(List l, String delimiter, String beginList, String endList) { StringBuffer sb = new StringBuffer(); sb.append(beginList); // append first item Iterator i = l.iterator(); if (i.hasNext()) { String item = (String) (i.next()); sb.append(item); } // append the rest of items while (i.hasNext()) { String items = (String) (i.next()); sb.append(delimiter + items); } sb.append(endList); return sb.toString(); } }