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: Apache License import java.util.Iterator; public class Main { public static <T> String join(Iterable<T> coll, String sep) { Iterator<T> it = coll.iterator(); String ret = ""; while (it.hasNext()) { ret = ret + it.next();/* ww w.j a va 2 s. com*/ if (it.hasNext()) { ret = ret + sep; } } return ret; } }