Here you can find the source of join(Iterable
public static <T> String join(Iterable<T> coll, String sep)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; public class Main { public static <T> String join(T[] arr, String sep) { String ret = ""; for (int i = 0; i < arr.length; i++) { ret = ret + arr[i];//from w ww. j av a 2s.c o m if (i < arr.length - 1) { ret = ret + sep; } } return ret; } public static <T> String join(Iterable<T> coll, String sep) { Iterator<T> it = coll.iterator(); String ret = ""; while (it.hasNext()) { ret = ret + it.next(); if (it.hasNext()) { ret = ret + sep; } } return ret; } }