Java Collection Join join(Collection strings, String separator)

Here you can find the source of join(Collection strings, String separator)

Description

join

License

Open Source License

Declaration

public static String join(Collection strings, String separator) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

public class Main {
    public static String join(String[] strings, String separator) {
        if (strings.length == 0) {
            return "";
        }/*from w  ww  .j  ava  2  s  . c o  m*/

        StringBuffer list = new StringBuffer(strings[0]);
        for (int i = 1; i < strings.length; i++)
            list.append(separator + strings[i]);

        return list.toString();
    }

    public static String join(Collection strings, String separator) {
        return join((String[]) strings.toArray(new String[0]), separator);
    }
}

Related

  1. join(Collection paramCollection, String paramString)
  2. join(Collection parts, String sep)
  3. join(Collection s, String delimiter)
  4. join(Collection s, String delimiter, boolean doQuote)
  5. join(Collection strings, String sep)
  6. join(Collection tokens, String separator)
  7. join(Collection var0, Object var1)
  8. join(Collection c, String joinWith)
  9. join(Collection collection, String joinString)