import java.util.*; public class foo { public static void main(String[] a) { Collection c = new HashSet(); for(int i = 1; i <= 5; i++) c.add( (double)i ); // add element to collection if ( ! c.isEmpty() ) System.out.println("c has " + c.size() + " elements"); for(Double d : c ) // iterate through a collection! System.out.println("c has " + d ); } }