Here you can find the source of join(Collection
public static String join(Collection<String> strings, String sep)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static String join(Collection<String> strings, String sep) { if (strings.isEmpty()) { return ""; }//from w ww.j a va 2 s .co m StringBuilder sb = new StringBuilder(); for (String parameterName : strings) { sb.append(parameterName).append(sep); } String names = sb.substring(0, sb.length() - sep.length()); return names; } /** * isEmpty compatible with Java 5 */ public static boolean isEmpty(String s) { return s == null || s.length() == 0; } }