Here you can find the source of join(String delim, Collection> col)
private static String join(String delim, Collection<?> col)
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.Iterator; public class Main { private static String join(String delim, Collection<?> col) { StringBuilder sb = new StringBuilder(); Iterator<?> iter = col.iterator(); if (iter.hasNext()) sb.append(iter.next().toString()); while (iter.hasNext()) { sb.append(delim);//from ww w .j av a 2 s. c om sb.append(iter.next().toString()); } return sb.toString(); } }