Here you can find the source of join(List
public static String join(List<String> values, String string)
//package com.java2s; //License from project: Apache License import java.util.List; public class Main { public static String join(List<String> values, String string) { StringBuilder sb = new StringBuilder(); int c = values.size(); for (String val : values) { if (c-- > 1) sb.append(val + string); else//from w w w . j a v a 2 s .co m sb.append(val); } return sb.toString(); } }