Here you can find the source of join(String sep, Collection> values)
public static String join(String sep, Collection<?> values)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { /**/*from w w w . jav a 2 s . co m*/ * Join collection into a single string, with a separator between. */ public static String join(String sep, Collection<?> values) { StringBuilder builder = new StringBuilder(); join(builder, sep, values); return builder.toString(); } /** * Join collection into and append to a StringBuilder, with a separator between. * Useful if you want to join strings and append to an existing StringBuilder. * @param builder StringBuilder you want to append to. This variable will be modified. * @param sep Separator between strings * @param values collection of strings to join. */ public static void join(StringBuilder builder, String sep, Collection<?> values) { boolean first = true; for (Object o : values) { if (first) first = false; else builder.append(sep); builder.append("" + o); } } /** * Join an multi value list into a single string, with a separator between. */ public static <T> void join(StringBuilder builder, String sep, T... values) { boolean first = true; for (Object o : values) { if (first) first = false; else builder.append(sep); builder.append("" + o); } } /** * Join an multi value list into a single string, with a separator between. */ public static <T> String join(String sep, T... values) { StringBuilder builder = new StringBuilder(); join(builder, sep, values); return builder.toString(); } }