Here you can find the source of join(List
public static String join(List<String> list, String delimiter)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { public static String join(List<String> list, String delimiter) { return join(list, delimiter, ""); }/* ww w.j a va2 s .c o m*/ public static String join(List<String> list, String delimiter, String surround) { StringBuilder sb = new StringBuilder(); boolean isFirst = true; for (String s : list) { if (isFirst) { isFirst = false; } else { sb.append(delimiter); } sb.append(surround); sb.append(s); sb.append(surround); } return sb.toString(); } }