Here you can find the source of join(CharSequence p, Collection> collection)
public static String join(CharSequence p, Collection<?> collection)
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { public static String join(CharSequence p, Collection<?> collection) { StringBuilder sb = new StringBuilder(); boolean f = true; for (Object c : collection) { if (f) f = false;//from w w w .ja va2 s.c o m else sb.append(p); sb.append(c.toString()); } return sb.toString(); } }