Here you can find the source of join(Collection
public static <T extends Object> String join(Collection<T> list, final String separator)
//package com.java2s; import java.util.Collection; public class Main { public static <T extends Object> String join(Collection<T> list, final String separator) { if (list == null) { return null; }//w w w. ja v a 2 s .co m final StringBuilder buf = new StringBuilder(); for (T item : list) { if (buf.length() > 0) { buf.append(separator); } if (item != null) { buf.append(item); } } return buf.toString(); } }