Here you can find the source of join(String connector, Object... objects)
public static String join(String connector, Object... objects)
//package com.java2s; //License from project: Open Source License import java.util.List; import java.util.Set; public class Main { /** EMPTY [String] */ public static final String EMPTY = ""; public static String join(String connector, Object... objects) { StringBuffer sBuffer = new StringBuffer(); for (Object object : objects) { sBuffer.append(object).append(connector); }//from w ww . j a v a 2s. c o m if (sBuffer.length() > 0) { sBuffer.delete(sBuffer.length() - connector.length(), sBuffer.length()); } return sBuffer.toString(); } public static String join(String connector, String[] arr) { StringBuffer sBuffer = new StringBuffer(); for (Object object : arr) { sBuffer.append(object).append(connector); } if (sBuffer.length() > 0) { sBuffer.delete(sBuffer.length() - connector.length(), sBuffer.length()); } return sBuffer.toString(); } public static String join(String connector, List<String> objects) { StringBuffer sBuffer = new StringBuffer(); for (String object : objects) { sBuffer.append(object).append(connector); } if (sBuffer.length() > 0) { sBuffer.delete(sBuffer.length() - connector.length(), sBuffer.length()); } return sBuffer.toString(); } public static String join(String connector, Set<String> objects) { StringBuffer sBuffer = new StringBuffer(); for (String object : objects) { sBuffer.append(object).append(connector); } if (sBuffer.length() > 0) { sBuffer.delete(sBuffer.length() - connector.length(), sBuffer.length()); } return sBuffer.toString(); } public static String toString(Object object) { return object == null ? EMPTY : object.toString(); } }