An Iterator from TreeSet presents elements in some kind of sorted order. : TreeSet « Utility Classes « SCJP






import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

public class MainClass {
  public static void main(String[] argv) {
    Set set = new TreeSet();
    set.add("1");
    set.add("2");
    set.add("3");

    Iterator it = set.iterator();
    while (it.hasNext()) {
      System.out.println(it.next());
    }

  }
}
1
2
3








8.17.TreeSet
8.17.1.An Iterator from TreeSet presents elements in some kind of sorted order.
8.17.2.The TreeSet class implements the java.util.SortedSet interface, which extends java.util.Set.
8.17.3.Use TreeSet to sort random numbers
8.17.4.Navigating (Searching) TreeSets and TreeMaps