Here you can find the source of join(CharSequence separator, Collection
public static String join(CharSequence separator, Collection<CharSequence> values)
//package com.java2s; import java.util.Collection; public class Main { public static String join(CharSequence separator, Collection<CharSequence> values) { StringBuffer sb = new StringBuffer(); for (CharSequence value : values) { if (sb.length() > 0) { sb.append(separator);//from w ww . jav a 2 s. co m } sb.append(value); } return sb.toString(); } }