Here you can find the source of join(List l, String sep)
public static String join(List l, String sep)
//package com.java2s; import java.util.List; public class Main { public static String join(String[] fields, String sep) { StringBuffer answer = new StringBuffer(); if (fields != null && fields.length > 0) { answer.append(fields[0]);/* w w w . j av a2 s . co m*/ for (int i = 1; i < fields.length; i++) { answer.append(sep); answer.append(fields[i]); } } return answer.toString(); } public static String join(List l, String sep) { String[] fields = (String[]) l.toArray(new String[l.size()]); return join(fields, sep); } }