Java Collection Join join(Collection strings, String separator)

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

Description

join

License

Apache License

Declaration

public static String join(Collection<String> strings, String separator) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Collection;
import java.util.Iterator;

public class Main {
    public static String join(Collection<String> strings) {
        return join(strings, ", ");
    }// w  w w  .  j av a  2 s. co  m

    public static String join(Collection<String> strings, String separator) {
        Iterator<String> iter = strings.iterator();
        StringBuilder sb = new StringBuilder();
        while (iter.hasNext()) {
            sb.append(iter.next());
            if (iter.hasNext()) {
                sb.append(separator);
            }
        }
        return sb.toString();
    }
}

Related

  1. join(Collection strings, String delimiter)
  2. join(Collection strings, String delimiter)
  3. join(Collection strings, String sep)
  4. join(Collection strings, String sep)
  5. join(Collection strings, String separator)
  6. join(Collection strings, String token)
  7. join(Collection strs, String sep)
  8. join(Collection thisPath, String _delim)
  9. join(Collection values)