Java Utililty Methods Collection Print

List of utility methods to do Collection Print

Description

The list of methods to do Collection Print are organized into topic(s).

Method

voidprint(Collection coll)
print
if (coll == null)
    throw new NullPointerException();
if (coll.isEmpty())
    return;
for (T t : coll) {
    System.out.println(t);
Stringprint(Collection elements)
Returns a String representation of given collection, separated by comma and surrounded by square brackets.
return print(elements, ",", "[", "]");
Stringprint(java.util.Collection collection)
Return a String representing the elements of collection in a human readable format.
StringBuffer sb = new StringBuffer("{ ");
java.util.Iterator iter = collection.iterator();
while (iter.hasNext()) {
    Object elem = iter.next();
    sb.append(elem.toString());
    if (iter.hasNext()) {
        sb.append(", ");
sb.append(" }");
return sb.toString();
StringprintCollection(Collection c)
Utility method to print a collection.
if (c != null) {
    StringBuffer sb = new StringBuffer("[");
    Iterator itr = c.iterator();
    while (itr.hasNext()) {
        sb.append(itr.next());
        if (itr.hasNext()) {
            sb.append(", ");
    sb.append("]");
    return sb.toString();
} else {
    return "[null]";
voidprintCollection(Collection col)

Print contents of collection.

if (col != null) {
    Iterator itr = col.iterator();
    while (itr.hasNext()) {
        System.out.println(itr.next().toString());
voidprintCollection(Collection collection)
print Collection
Iterator itr = collection.iterator();
System.out.println("-----Printing Collection-----");
while (itr.hasNext()) {
    System.out.println(itr.next());
System.out.println("-----End Of Collection-----");
StringprintCollection(Collection l)
print Collection
return printCollection(l, "");
voidprintCollection(Collection col)
Provides a way to print a collection
for (Object next : col)
    System.out.println(next.toString());
voidprintCollection(Collection collections)
print Collection
for (T t : collections) {
    System.out.print(t);
    System.out.print(" ");
System.out.println();
voidprintCollection(final Collection collection)
Helper-Method for printing a Collection in the console.
int count = 1;
for (T element : collection) {
    System.err.println(count + ".)element:" + element);
    count++;