Here you can find the source of join(Iterable> items, String separator)
public static String join(Iterable<?> items, String separator)
//package com.java2s; //License from project: Apache License import java.util.Arrays; import java.util.Iterator; public class Main { /**/* w w w . j av a 2 s . com*/ * Creates a string by concatenating items array of specified items, * separating each with the specified separator. */ public static String join(String[] items, String separator) { return join(Arrays.asList(items), separator); } /** * Same as {@link #join(String[], String)} but expecting an {@link Iterable} * instead of an array */ public static String join(Iterable<?> items, String separator) { final StringBuilder builder = new StringBuilder(); final Iterator<?> it = items.iterator(); while (it.hasNext()) { builder.append(it.next().toString()); if (it.hasNext()) { builder.append(separator); } } return builder.toString(); } }