Here you can find the source of join(Collection> objs, String sep)
public static String join(Collection<?> objs, String sep)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { /**//from ww w . j a va2 s. c o m * Join a collection with a separator string */ public static String join(Collection<?> objs, String sep) { StringBuilder sb = new StringBuilder(); boolean first = true; for (Object obj : objs) { if (!first) { sb.append(sep); } sb.append(obj.toString()); first = false; } return sb.toString(); } /** * Join an array with a separator string */ public static <T> String join(T[] array, String sep) { StringBuilder sb = new StringBuilder(); boolean first = true; for (T e : array) { if (!first) { sb.append(sep); } sb.append(e.toString()); first = false; } return sb.toString(); } }