Java Collection Join join(Collection coll, String delimiter)

Here you can find the source of join(Collection coll, String delimiter)

Description

Returns the joined string.

License

Open Source License

Parameter

Parameter Description
coll the collection of strings to join.
delimiter the delimiter.

Return

the joined string.

Declaration

public static String join(Collection<String> coll, String delimiter) 

Method Source Code


//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();
    }
}

Related

  1. join(Collection c, String separator)
  2. join(Collection args, String delimeter)
  3. join(Collection c)
  4. join(Collection c, String joinSymbol)
  5. join(Collection coll, String delimiter)
  6. join(Collection collection)
  7. join(Collection collection)
  8. join(Collection collection, String separator)
  9. join(Collection collection, String separator)