Here you can find the source of join(Collection collection, String s)
public static String join(Collection collection, String s)
//package com.java2s; import java.util.*; public class Main { public static String join(Collection collection, String s) { String s1;/*from ww w .j a va 2s.c o m*/ if (collection.size() == 0) { s1 = ""; } else { StringBuilder stringbuilder = new StringBuilder(); for (Iterator iterator = collection.iterator(); iterator .hasNext();) { String s2 = (String) iterator.next(); StringBuilder stringbuilder1 = stringbuilder.append(s2) .append(s); } if (stringbuilder.length() > 0) { int i = stringbuilder.length() - 1; int j = stringbuilder.length(); StringBuilder stringbuilder2 = stringbuilder.delete(i, j); } s1 = stringbuilder.toString(); } return s1; } }