Here you can find the source of join(StringBuilder builder, Collection
public static StringBuilder join(StringBuilder builder, Collection<String> strs)
//package com.java2s; //License from project: Apache License import java.util.Collection; import java.util.List; public class Main { public static String join(List<String> strs) { return join(new StringBuilder(), strs).toString(); }/*from w w w. j ava2 s . c om*/ public static String join(String[] strs) { return join(new StringBuilder(), strs).toString(); } public static StringBuilder join(StringBuilder builder, Collection<String> strs) { int i = 0; for (String s : strs) { if (i != 0) builder.append(','); builder.append(s); i++; } return builder; } public static StringBuilder join(StringBuilder builder, String[] strs) { for (int i = 0; i < strs.length; i++) { if (i != 0) builder.append(","); builder.append(strs[i]); } return builder; } }