Here you can find the source of join(ArrayList
public static <H> String join(ArrayList<H> arr, String separator)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { public static String join(Object[] arr, String separator) { if (separator == null) { separator = ","; }/*from w w w.ja va 2s. co m*/ StringBuilder sb = new StringBuilder(); for (int i = 0; i < arr.length; i++) { if (i > 0) { sb.append(separator); } sb.append(arr[i].toString()); } return sb.toString(); } public static <H> String join(ArrayList<H> arr, String separator) { if (separator == null) { separator = ","; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < arr.size(); i++) { if (i > 0) { sb.append(separator); } sb.append(arr.get(i).toString()); } return sb.toString(); } }