Here you can find the source of join(String... xs)
public static String join(String... xs)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { public static String join(String... xs) { StringBuilder sb = new StringBuilder(); for (String x : xs) sb.append(x);/*from ww w .j a v a2s .c om*/ return sb.toString(); } public static String join(List<String> xs) { StringBuilder sb = new StringBuilder(); for (String x : xs) sb.append(x); return sb.toString(); } public static String join(List<String> xs, String sep) { int sepLen = sep.length(); StringBuilder sb = new StringBuilder(); for (String x : xs) sb.append(x).append(sep); return sb.length() > 0 ? sb.delete(sb.length() - sepLen, sb.length()).toString() : ""; } }