Here you can find the source of join(List
public static String join(List<String> list)
//package com.java2s; //License from project: GNU General Public License import java.util.Iterator; import java.util.List; public class Main { public static String join(List<String> list) { return join(list, " "); }/*from w ww . ja v a2s. c o m*/ public static String join(List<String> list, String separator) { Iterator<String> iter = list.iterator(); String result = iter.hasNext() ? iter.next().toString() : ""; while (iter.hasNext()) result += separator + iter.next(); return result; } public static String join(String[] list, String separator) { String result = list.length > 0 ? list[0] : ""; for (int i = 1; i < list.length; i++) result += separator + list[i]; return result; } }