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