Java examples for java.util:Collection Element
Prints the collection elements to the console
//package com.book2s; import java.util.Collection; import java.util.Iterator; public class Main { public static void main(String[] argv) { Collection c = java.util.Arrays.asList("asdf", "book2s.com"); printToConsole(c);//w w w . j a va 2 s . c o m } /** * Prints the collection elements to the console * @param c the collection to print out */ public static <E> void printToConsole(Collection<E> c) { Iterator<E> itr = c.iterator(); while (itr.hasNext()) { System.out.print(itr.next() + " "); } System.out.println(); } }