/Users/lyon/j4p/src/collections/hashset/HashSetTest.java

1    /* 
2     * HashSetTest.java 
3     * 
4     * Created on December 3, 2002 
5     */ 
6     
7    package collections.hashset; 
8     
9    import java.util.HashSet; 
10   import java.util.Iterator; 
11   import java.util.Set; 
12    
13   /** 
14    * Demonstrates how to add objects to a HashSet 
15    * and retrieve them. 
16    * @author  Thomas Rowland 
17    */ 
18   public class HashSetTest { 
19    
20       public static void main(String[] args) { 
21           Set hs = new HashSet(); 
22           hs.add("Jerry"); 
23           hs.add("Bob"); 
24           hs.add("Phil"); 
25    
26           // print out the names 
27           Iterator i = hs.iterator(); 
28           while (i.hasNext()) { 
29               System.out.println((String) i.next()); 
30           } 
31       } 
32   } 
33