Here you can find the source of join(Collection
public static String join(Collection<String> s, String delimiter)
//package com.java2s; import java.util.Collection; import java.util.Iterator; public class Main { /**/*from w ww . j a v a 2s .c o m*/ * Join a collection of objects into a single string string separated by a * delimiter * * @note see http://snippets.dzone.com/posts/show/91 */ public static String join(Collection<String> s, String delimiter) { if (s.isEmpty()) return ""; Iterator<String> iter = s.iterator(); StringBuffer buffer = new StringBuffer(iter.next()); while (iter.hasNext()) buffer.append(delimiter).append(iter.next()); return buffer.toString(); } }