Here you can find the source of join(final Collection
public static String join(final Collection<String> seq, final String delimiter)
//package com.java2s; /* Copyright c 2005-2012. * Licensed under GNU LESSER General Public License, Version 3. * http://www.gnu.org/licenses/*from ww w . ja va 2 s.c o m*/ */ import java.util.Collection; public class Main { public static final String DELIMITER = ","; public static String join(final String[] seq, final String delimiter) { if (null == seq || seq.length < 1) { return ""; } else { StringBuilder aim = new StringBuilder(); for (int i = 0; i < seq.length; i++) { if (null != delimiter && aim.length() > 0) { aim.append(delimiter); } aim.append(seq[i]); } return aim.toString(); } } public static String join(final Collection<String> seq, final String delimiter) { if (null == seq || seq.size() < 1) { return ""; } else { StringBuilder aim = new StringBuilder(); for (String one : seq) { if (null != delimiter && aim.length() > 0) { aim.append(delimiter); } aim.append(one); } return aim.toString(); } } public static String join(final String... seq) { return join(seq, DELIMITER); } }