Create TreeSet and add value to it - Java Collection Framework

Java examples for Collection Framework:TreeSet

Description

Create TreeSet and add value to it

Demo Code


import java.util.TreeSet;;
 
public class Main {
 
  public static void main(String[] args) {
    TreeSet tSet = new TreeSet();
   //ww w  . j a v a2  s. com
    tSet.add(new Integer("1"));
    tSet.add(new Integer("2"));
    tSet.add(new Integer("3"));
   
    System.out.println("TreeSet contains.." + tSet);  
  }
}
 

Result


Related Tutorials