Here you can find the source of join(List
public static String join(List<String> s, String delimiter)
//package com.java2s; import java.util.Iterator; import java.util.List; public class Main { public static String join(List<String> s, String delimiter) { if (s == null || s.isEmpty()) { return ""; }/* ww w. j av a2 s. com*/ Iterator<String> iter = s.iterator(); StringBuilder builder = new StringBuilder(iter.next()); while (iter.hasNext()) { builder.append(delimiter).append(iter.next()); } return builder.toString(); } }