Here you can find the source of joinStrings(Iterable
public static String joinStrings(Iterable<String> list)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; public class Main { /**// ww w. ja v a2 s . co m * same as {@link #joinStrings(Iterable, String)}, and default {@code sep} to empty string */ public static String joinStrings(Iterable<String> list) { return joinStrings(list, ""); } /** * join a list of string to a string with {@code sep}. * * @param list the string list * @param sep the separator */ public static String joinStrings(Iterable<String> list, String sep) { if (list == null) return ""; StringBuffer sb = new StringBuffer(); for (Iterator<String> it = list.iterator(); it.hasNext();) { sb.append(it.next()); if (it.hasNext()) { sb.append(sep); } } return sb.toString(); } }