Here you can find the source of join(Collection> s, String delimiter)
public static String join(Collection<?> s, String delimiter)
//package com.java2s; import java.util.Collection; import java.util.Iterator; public class Main { public static String join(Collection<?> s, String delimiter) { return join(s, delimiter, null); }/*from www . j ava 2s.c o m*/ public static String join(Collection<?> s, String delimiter, String prefix) { StringBuilder builder = new StringBuilder(); Iterator<?> iter = s.iterator(); while (iter.hasNext()) { if (!IsNullOrEmpty(prefix)) { builder.append(prefix); } builder.append(iter.next()); if (!iter.hasNext()) { break; } builder.append(delimiter); } return builder.toString(); } public static boolean IsNullOrEmpty(String string) { return (string == null || string.length() == 0); } }