Here you can find the source of join(List
public static String join(List<String> strings, String separator)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { public static String join(List<String> strings, String separator) { if (strings == null || strings.isEmpty()) { return ""; }//from w w w. jav a 2 s . c om StringBuilder b = new StringBuilder(); for (int i = 0;; i++) { b.append(strings.get(i)); if (i == strings.size() - 1) { return b.toString(); } b.append(separator); } } }