Java Collection Print printCollection(String name, Collection collection)

Here you can find the source of printCollection(String name, Collection collection)

Description

print Collection

License

Apache License

Declaration

public static void printCollection(String name, Collection<? extends Object> collection) 

Method Source Code


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

import java.util.Collection;

public class Main {
    public static void printCollection(String name, Collection<? extends Object> collection) {
        StringBuilder sb = new StringBuilder();
        sb.append(name);//from   w w  w. ja v  a 2 s  .  c  o m
        sb.append(": [");
        java.util.Iterator<? extends Object> it = collection.iterator();
        int i = 0;
        while (it.hasNext()) {
            sb.append(it.next());
            if (i < collection.size() - 1)
                sb.append(", ");
            i++;
        }
        sb.append("]");
        System.out.println(sb.toString());
    }
}

Related

  1. printCollection(Collection collection)
  2. printCollection(Collection l)
  3. printCollection(Collection col)
  4. printCollection(Collection collections)
  5. printCollection(final Collection collection)
  6. printCollectionDebug(Collection c)
  7. printCollectionSorted(Collection l, String indent)
  8. printElement(Collection pCollection, boolean pAllElement)
  9. printElementsUnderCollection(Collection collection)