Here you can find the source of join(Collection
public static String join(Collection<String> strs, String sep)
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { public static String join(String[] strs, String sep) { StringBuilder bud = new StringBuilder(); for (String s : strs) { if (bud.length() > 0) bud.append(sep);/*from ww w. ja v a 2s.c o m*/ bud.append(s); } return bud.toString(); } public static String join(Collection<String> strs, String sep) { StringBuilder bud = new StringBuilder(); for (String s : strs) { if (bud.length() > 0) bud.append(sep); bud.append(s); } return bud.toString(); } }