Here you can find the source of listToString(Iterable> list)
public static String listToString(Iterable<?> list)
//package com.java2s; //License from project: Apache License import java.util.Iterator; public class Main { public static String listToString(Iterable<?> list) { if (list == null) { return ""; }/*from w ww . j a v a 2 s.c om*/ StringBuilder str = new StringBuilder(); for (Iterator<?> it = list.iterator(); it.hasNext();) { Object o = it.next(); str.append(o); if (it.hasNext()) { str.append(", "); } } return str.toString(); } }