Here you can find the source of join(String sep, List
private static String join(String sep, List<String> a)
//package com.java2s; import java.util.List; public class Main { private static String join(String sep, List<String> a) { return join(sep, a.toArray(new String[0])); }// w ww . ja v a2 s . co m private static String join(String sep, String... a) { if (a.length == 0) return ""; if (a.length == 1) return a[0]; StringBuffer sbuff = new StringBuffer(); sbuff.append(a[0]); for (int i = 1; i < a.length; i++) { if (sep != null) sbuff.append(sep); sbuff.append(a[i]); } return sbuff.toString(); } }