Here you can find the source of join(String glue, Iterable
public static String join(String glue, Iterable<String> items)
//package com.java2s; //License from project: Open Source License import java.util.Arrays; public class Main { public static String join(String glue, String[] items) { return join(glue, Arrays.asList(items)); }/* w ww.jav a 2 s . co m*/ public static String join(String glue, Iterable<String> items) { StringBuilder ret = new StringBuilder(); boolean first = true; for (String item : items) { if (first) { first = false; } else { ret.append(glue); } ret.append(item); } return ret.toString(); } }