Here you can find the source of join(String delimiter, Collection extends Object> objects)
public static String join(String delimiter, Collection<? extends Object> objects)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static final String EMPTY_STRING = ""; public static String join(String delimiter, Object... objects) { return join(delimiter, Arrays.asList(objects)); }//from w w w . j av a 2s . c o m public static String join(String delimiter, Collection<? extends Object> objects) { if (objects == null || objects.isEmpty()) { return EMPTY_STRING; } Iterator<? extends Object> iterator = objects.iterator(); StringBuilder builder = new StringBuilder(); builder.append(iterator.next()); while (iterator.hasNext()) { builder.append(delimiter).append(iterator.next()); } return builder.toString(); } }