Here you can find the source of join(Iterable
public static String join(Iterable<String> input)
//package com.java2s; import java.util.Arrays; public class Main { /**/*from ww w . ja v a2s.c om*/ * Returns a comma-separated join of the strings in the input. */ public static String join(Iterable<String> input) { StringBuilder builder = new StringBuilder(); for (String item : input) { builder.append(item).append(", "); } if (builder.length() >= 2) { builder.setLength(builder.length() - 2); } return builder.toString(); } /** * Returns a comma-separated join of the strings in the input. */ public static String join(String[] input) { return join(Arrays.asList(input)); } }