Java Collection Join join(Collection s, String delimiter)

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

Description

join

License

Open Source License

Declaration

public static <T> String join(Collection<T> s, String delimiter) 

Method Source Code

//package com.java2s;

import java.util.Collection;

import java.util.Iterator;

public class Main {
    public static <T> String join(Collection<T> s, String delimiter) {
        StringBuffer buffer = new StringBuffer();
        Iterator<T> iter = s.iterator();
        while (iter.hasNext()) {
            buffer.append(iter.next());/*from  w  w  w . ja v a 2 s .com*/
            if (iter.hasNext()) {
                buffer.append(delimiter);
            }
        }
        return buffer.toString();
    }
}

Related

  1. join(Collection collection, CharSequence joinedBy)
  2. join(Collection collection, String joinString)
  3. join(Collection collections, String separator)
  4. join(Collection list, final String separator)
  5. join(Collection list, String delimiter)
  6. join(Collection things, String delim)
  7. join(Collection values, String join)
  8. join(final char _separator, final boolean _quotes, final Collection _list, final String _emptyString)
  9. join(final Collection collection, String delimiter)