Here you can find the source of join(Collection
public static String join(Collection<String> list, String conjunction)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { public static String join(Collection<String> list, String conjunction) { StringBuilder sb = new StringBuilder(); if (conjunction == null) { conjunction = ", "; }/*from w w w. ja v a 2 s . c o m*/ if (list != null && !list.isEmpty()) { for (String string : list) { sb.append(string).append(conjunction); } sb.setLength(sb.length() - conjunction.length()); } return sb.toString(); } }