Here you can find the source of join(Iterable
public static String join(Iterable<String> items, String separator)
//package com.java2s; //License from project: Apache License import java.util.Arrays; import java.util.Iterator; public class Main { public static String join(String[] items, String separator) { return join(Arrays.asList(items), separator); }/* w ww . jav a 2s .c o m*/ public static String join(Iterable<String> items, String separator) { final StringBuilder builder = new StringBuilder(); final Iterator<String> it = items.iterator(); while (it.hasNext()) { builder.append(it.next()); if (it.hasNext()) { builder.append(separator); } } return builder.toString(); } public static String toString(Object object) { if (object == null) { return "null"; } return object.toString(); } public static String toString(Iterable<?> it, String separator) { final StringBuilder builder = new StringBuilder(); final Iterator<?> iterator = it.iterator(); while (iterator.hasNext()) { builder.append(iterator.next().toString()); if (iterator.hasNext()) { builder.append(separator); } } return builder.toString(); } }