Java Collection Join join(Collection list, final String separator)

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

Description

join

License

Open Source License

Declaration

public static <T extends Object> String join(Collection<T> list, final String separator) 

Method Source Code


//package com.java2s;
import java.util.Collection;

public class Main {
    public static <T extends Object> String join(Collection<T> list, final String separator) {
        if (list == null) {
            return null;
        }//w  w w.  ja v  a  2 s  .co m
        final StringBuilder buf = new StringBuilder();
        for (T item : list) {
            if (buf.length() > 0) {
                buf.append(separator);
            }
            if (item != null) {
                buf.append(item);
            }
        }
        return buf.toString();
    }
}

Related

  1. join(Collection coll, String separator)
  2. join(Collection collec, String delimiter)
  3. join(Collection collection, CharSequence joinedBy)
  4. join(Collection collection, String joinString)
  5. join(Collection collections, String separator)
  6. join(Collection list, String delimiter)
  7. join(Collection s, String delimiter)
  8. join(Collection things, String delim)
  9. join(Collection values, String join)