Here you can find the source of join(String joinString, List
public static String join(String joinString, List<String> strings)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { public static String join(String joinString, List<String> strings) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < strings.size(); ++i) { sb.append(strings.get(i));/*from w w w .j av a 2 s . c om*/ if (i + 1 < strings.size()) { sb.append(joinString); } } return sb.toString(); } public static String join(String joinString, String[] strings) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < strings.length; ++i) { sb.append(strings[i]); if (i + 1 < strings.length) { sb.append(joinString); } } return sb.toString(); } public static String join(char joinChar, List<String> strings) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < strings.size(); ++i) { sb.append(strings.get(i)); if (i + 1 < strings.size()) { sb.append(joinChar); } } return sb.toString(); } }