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

voidprintCollection(String name, Collection collection)
print Collection
StringBuilder sb = new StringBuilder();
sb.append(name);
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)
...
voidprintCollectionDebug(Collection c)
print Collection Debug
System.out.println(c.size() + ":  " + c);
StringprintCollectionSorted(Collection l, String indent)
print Collection Sorted
List sortedCollection = new ArrayList(l);
Collections.sort(sortedCollection);
return printCollection(sortedCollection, indent);
StringprintElement(Collection pCollection, boolean pAllElement)
For Testing use.
int size = pCollection.size();
if (!pAllElement && size > 10) {
    size = 10;
StringBuffer buf = new StringBuffer();
Iterator<?> iter = pCollection.iterator();
for (int i = 0; i < size; i++) {
    buf.append(i).append("= ").append(iter.next()).append(ANEMPTYSPACE);
...
voidprintElementsUnderCollection(Collection collection)
Prints the elements under collection.
for (Object object : collection) {
    System.out.println(object);
voidprintList(Collection collection)
print List
System.out.print("[ ");
for (Object value : collection)
    System.out.print(value + ",\t");
System.out.println(" ]");
voidprintln(Collection lines, String suffix, String prefix)
println
System.out.println(toString(lines, suffix, prefix));
voidprintMatrixList(Collection collection)
print Matrix List
System.out.println("*** Start of list");
for (Object[][] matrix : collection) {
    printMatrix(matrix);
    System.out.println("-----");
System.out.println("*** End of list");
voidprintObjectArray(Collection valueArrays)
print Object Array
System.out.println("[");
for (Iterator iterator = valueArrays.iterator(); iterator.hasNext();) {
    Object[] values = (Object[]) iterator.next();
    System.out.print("[");
    for (int i = 0; i < values.length; i++) {
        Object value = values[i];
        System.out.print(value);
        if ((i + 1) < values.length)
...