Here you can find the source of join(CharSequence[] strings, CharSequence separator)
public static String join(CharSequence[] strings, CharSequence separator)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { /**//w w w .j a v a 2s. c o m * Joins the strings in 'strings' with 'separator' between each. */ public static String join(CharSequence[] strings, CharSequence separator) { StringBuilder result = new StringBuilder(); for (CharSequence string : strings) { if (result.length() > 0) { result.append(separator); } result.append(string); } return result.toString(); } /** * Joins the strings in 'strings' with 'separator' between each. */ public static String join(Iterable<?> strings, CharSequence separator) { StringBuilder result = new StringBuilder(); boolean first = true; Iterator<?> it = strings.iterator(); while (it.hasNext()) { if (first) { first = false; } else { result.append(separator); } result.append(it.next()); } return result.toString(); } }