Here you can find the source of toString(Iterable
public static String toString(Iterable<String> strs)
//package com.java2s; import java.util.Iterator; public class Main { public static String toString(Iterable<String> strs) { StringBuilder ret = new StringBuilder(); for (Iterator<String> i = strs.iterator(); i.hasNext();) { ret.append(i.next());/*from ww w. j a v a2 s .co m*/ if (i.hasNext()) ret.append(","); } return ret.toString(); } }