Here you can find the source of commalist(List l)
public static String commalist(List l)
//package com.java2s; import java.util.Iterator; import java.util.List; public class Main { public static final String COMMA = ","; public static String commalist(List l) { StringBuffer buf = new StringBuffer(); commalist(l, buf);//from w ww.j a v a 2 s . c o m return buf.toString(); } public static void commalist(List l, StringBuffer buf) { Iterator i = l.iterator(); while (i.hasNext()) { buf.append(i.next().toString()); if (i.hasNext()) buf.append(", "); } } public static String commalist(Object[] o) { StringBuffer buf = new StringBuffer(); commalist(o, buf); return buf.toString(); } public static void commalist(Object[] o, StringBuffer buf) { for (int cntr = 0; cntr < o.length; cntr++) { if (cntr > 0) buf.append(", "); buf.append(o[cntr].toString()); } } public static void commalist(Iterator i, StringBuffer buf) { for (int cntr = 0; i.hasNext(); cntr++) { if (cntr > 0) buf.append(", "); buf.append(i.next().toString()); } } public static String commalist(Object o1, Object o2) { return o1 + COMMA + o2; } public static String commalist(Object o1, Object o2, Object o3) { return o1 + COMMA + o2 + COMMA + o3; } public static String commalist(Object o1, Object o2, Object o3, Object o4) { return o1 + COMMA + o2 + COMMA + o3 + COMMA + o4; } }