/Users/lyon/j4p/src/collections/treeset/TreeSetTest.java

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