Java Collection to String toString(final Collection collection)

Here you can find the source of toString(final Collection collection)

Description

to String

License

Open Source License

Declaration

public final static String toString(final Collection<?> collection) 

Method Source Code


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

public class Main {
    public final static String toString(final Collection<?> collection) {
        if (collection == null) {
            return "null";
        }//from  w w w  .j  a  v  a 2 s .  c o m
        final StringBuilder s = new StringBuilder();
        for (final Iterator<?> i = collection.iterator(); i.hasNext();) {
            s.append(String.valueOf(i.next()));
            if (i.hasNext()) {
                s.append(", ");
            }
        }
        return s.toString();
    }
}

Related

  1. toString(Collection collection)
  2. toString(Collection collection)
  3. toString(Collection collection, String divider)
  4. toString(Collection list, String delimeter)
  5. toString(final Collection collection)
  6. toString(final Collection collection, final String separator)
  7. toString(final Collection objs)
  8. toString(final Collection values)
  9. toString(final Collection list, final String delimiter)