Here you can find the source of printCollection(String name, Collection extends Object> collection)
public static void printCollection(String name, Collection<? extends Object> collection)
//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()); } }