Here you can find the source of join(Collection> items, String delim)
public static String join(Collection<?> items, String delim)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { public static String join(Collection<?> items, String delim) { if (items.isEmpty()) { return ""; }//from ww w .j av a 2s.co m StringBuilder sb = new StringBuilder(); for (Object o : items) { sb.append(o.toString()); sb.append(delim); } sb.delete(sb.length() - delim.length(), sb.length()); return sb.toString(); } }