Here you can find the source of join(Iterable> c, String delimeter)
public static String join(Iterable<?> c, String delimeter)
//package com.java2s; //License from project: Open Source License import java.util.Iterator; public class Main { public static String join(Iterable<?> c, String delimeter) { StringBuilder sb = new StringBuilder(); Iterator<?> it = c.iterator(); while (it.hasNext()) { sb.append(it.next());//from w ww. j av a2s .c om if (!it.hasNext()) break; sb.append(delimeter); } return sb.toString(); } public static <T> String join(T[] c, String delimeter) { StringBuilder sb = new StringBuilder(); boolean first = true; for (T t : c) { if (first) first = false; else sb.append(delimeter); sb.append(t); } return sb.toString(); } }