Here you can find the source of join(Collection
public static <T> String join(Collection<T> things, String delim)
//package com.java2s; import java.util.Collection; import java.util.List; public class Main { public static <T> String join(Collection<T> things, String delim) { return join(things.toArray(), delim); }/*from w w w.j a v a 2 s.c o m*/ public static <T> String join(T[] things, String delim) { StringBuilder sb = new StringBuilder(); boolean first = true; for (T t : things) { if (first) first = false; else sb.append(delim); sb.append(t); } return sb.toString(); } public static String toString(List<?> arr) { return toString(arr, true); } public static String toString(List<?> arr, boolean square) { return toString(arr.toArray(), square); } public static String toString(Object[] arr) { return toString(arr, true); } public static String toString(Object[] arr, boolean square) { if (arr == null) return "null"; StringBuffer sb = new StringBuffer(); if (square) { sb.append("["); } else { sb.append("("); } for (int i = 0; i < arr.length; ++i) {//Object o : arr ) { if (i > 0) sb.append(","); if (arr[i] == null) { sb.append("null"); } else { sb.append(arr[i].toString()); } } if (square) { sb.append("]"); } else { sb.append(")"); } return sb.toString(); } }