Here you can find the source of join(Collection
Parameter | Description |
---|---|
coll | the collection of strings to join. |
delimiter | the delimiter. |
public static String join(Collection<String> coll, String delimiter)
//package com.java2s; import java.util.Collection; public class Main { /**/*from w w w . j a v a2s . c o m*/ * Returns the joined string. * * @param coll the collection of strings to join. * @param delimiter the delimiter. * @return the joined string. */ public static String join(Collection<String> coll, String delimiter) { StringBuilder buff = new StringBuilder(); for (String str : coll) { if (buff.length() > 0) { buff.append(delimiter); } buff.append(str); } return buff.toString(); } }