Here you can find the source of join(String conjunction, Collection
@SuppressWarnings("unchecked") public static <T> String join(String conjunction, Collection<T>... collections)
//package com.java2s; import java.util.Collection; public class Main { public static <T> String join(Collection<T>... collections) { return join(",", collections); }/*www . j a v a 2s . c o m*/ @SuppressWarnings("unchecked") public static <T> String join(String conjunction, Collection<T>... collections) { int length = collections.length; if (length == 0) return null; Collection<Object> collection = (Collection<Object>) collections[0]; if (length > 1) { for (int i = 1; i < length; i++) { collection.addAll(collections[i]); } } StringBuilder sb = new StringBuilder(); boolean first = true; for (Object obj : collection) { if (obj == null) break; if (first) first = false; else sb.append(conjunction); sb.append(obj.toString()); } return sb.toString(); } }