Set and TreeSet : Set : Collections Data Structure : Java examples (example source code) Organized by topic

Java
C++
PHP


Java  »  Collections Data Structure   » [  Set  ]  Screenshots 
 



Set and TreeSet


import java.util.*;
public class Comp {
  public static void main (String args[]) throws Exception {
    String elements[] {"Irish Setter""Poodle"
      "English Setter""Gordon Setter""Pug"};
    Set set = new TreeSet(Collections.reverseOrder());
    for (int i=0, n=elements.length; i<n; i++) {
      set.add(elements[i]);
    }
    System.out.println(set);
    System.out.println(((TreeSet)set).comparator());  
  }
}


           
       
Related examples in the same category
1.  Things you can do with Sets Things you can do with Sets
2.  Putting your own type in a Set Putting your own type in a Set
3.  Use set Use set
4.  Another Set demo
5.  Set substraction Set substraction
6.  Working with HashSet and TreeSet Working with HashSet and TreeSet
7.  TreeSet Demo TreeSet Demo
8.  Show the union and instersection of two sets
9.  Demonstrate the Set interface
10.  TreeSet Test
11.  Array Set extends AbstractSet Array Set extends AbstractSet
12.  Sync Test
13.  Set Copy
14.  Tail
15.  What you can do with a TreeSet What you can do with a TreeSet
























Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.