Here you can find the source of join(String sep, Collection
static String join(String sep, Collection<String> strings)
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { static String join(String sep, Collection<String> strings) { StringBuilder sb = new StringBuilder(); boolean first = true; for (String s : strings) { if (!first) { sb.append(sep);//from w ww. j a va2 s . c o m } else { first = false; } sb.append(s); } return sb.toString(); } static String join(char c, Collection<String> strings) { return join(String.valueOf(c), strings); } }