Here you can find the source of join(List
public static String join(List<String> list, String separator)
//package com.java2s; //License from project: Apache License import java.util.Arrays; import java.util.List; public class Main { public static String join(List<String> list, String separator, boolean ignoreNull) { if (list.isEmpty()) return ""; StringBuilder b = new StringBuilder(); for (String item : list) { if (!ignoreNull || item != null) { b.append(separator).append(item); }// w ww . j av a2 s. c o m } if (b.length() == 0) { return ""; } return b.toString().substring(separator.length()); } public static String join(List<String> list, String separator) { return join(list, separator, false); } public static String join(String[] array, String separator, boolean ignoreNull) { return join(Arrays.asList(array), separator, ignoreNull); } public static String join(String[] array, String separator) { return join(array, separator, false); } }