Here you can find the source of join(Collection> objs, String delim)
public static String join(Collection<?> objs, String delim)
//package com.java2s; // are made available under the terms of the Eclipse Public License v1.0 import java.util.Collection; public class Main { public static String join(Object[] arr, String delim) { if (arr == null) { return ""; }/*from www.j a va 2 s . c om*/ return join(arr, 0, arr.length, delim); } public static String join(Object[] arr, int start, int end, String delim) { if (arr == null) { return ""; } StringBuilder str = new StringBuilder(); for (int i = start; i < end; i++) { if (i > start) { str.append(delim); } str.append(arr[i]); } return str.toString(); } public static String join(Collection<?> objs, String delim) { if (objs == null) { return ""; } StringBuilder str = new StringBuilder(); boolean needDelim = false; for (Object obj : objs) { if (needDelim) { str.append(delim); } str.append(obj); needDelim = true; } return str.toString(); } }