Here you can find the source of join(String separator, Collection
public static String join(String separator, Collection<String> strings)
//package com.java2s; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright (c) 2012, Robin Jarry. All rights reserved. * * * * This file is part of APIWATCH and published under the BSD license. * * * * See the "LICENSE" file for more information. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ import java.util.Collection; public class Main { public static String join(String separator, Collection<String> strings) { if (separator == null) { throw new IllegalArgumentException("separator cannot be null"); }//from ww w. j ava 2 s . com if (strings != null && strings.size() > 0) { StringBuilder sb = new StringBuilder(); for (String s : strings) { sb.append(separator); sb.append(s); } return sb.substring(separator.length()); } else { return ""; } } }