public static String printCollection(Collection c){
  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]";
  }
}

public static String printCollection ( Collection c ) { 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]" ; } }
utility method to print a collection .
