Java Collection Print printCollection(Collection l)

Here you can find the source of printCollection(Collection l)

Description

print Collection

License

Open Source License

Declaration

public static String printCollection(Collection l) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;

public class Main {
    public static String printCollection(Collection l) {
        return printCollection(l, "");
    }/*from w w w  . j  a  v a2  s  .com*/

    public static String printCollection(Collection l, String indent) {
        if (l == null) {
            return indent + "(null)";
        }
        if (l.isEmpty()) {
            return indent + "(empty collection)";
        }
        StringBuilder result = new StringBuilder();
        for (Object o : l) {
            result.append(indent).append(o).append("\n");
        }
        result.deleteCharAt(result.length() - 1);
        return result.toString();
    }
}

Related

  1. print(Collection elements)
  2. print(java.util.Collection collection)
  3. printCollection(Collection c)
  4. printCollection(Collection col)
  5. printCollection(Collection collection)
  6. printCollection(Collection col)
  7. printCollection(Collection collections)
  8. printCollection(final Collection collection)
  9. printCollection(String name, Collection collection)