Here you can find the source of join(Iterable
public static <E> String join(Iterable<E> iterable, String separator)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; public class Main { public static <E> String join(Iterable<E> iterable, String separator) { if (iterable == null) return null; Iterator<E> iterator = iterable.iterator(); StringBuffer buf = new StringBuffer(256); while (iterator.hasNext()) { E elem = iterator.next();//from w ww . j a v a 2 s.com if (elem != null) buf.append(elem); if (iterator.hasNext()) buf.append(separator); } return buf.toString(); } }