List of usage examples for java.util TreeSet TreeSet
public TreeSet()
From source file:TreeSetDemo.java
public static void main(String args[]) { TreeSet<String> ts = new TreeSet<String>(); ts.add("C");/* ww w . ja va 2 s. c om*/ ts.add("A"); ts.add("B"); ts.add("E"); ts.add("F"); ts.add("D"); System.out.println(ts); }
From source file:Main.java
public static void main(String[] args) { TreeSet<String> tSet = new TreeSet<String>(); tSet.add("1"); tSet.add("2"); tSet.add("3"); tSet.add("4"); tSet.add("5"); boolean blnExists = tSet.contains("3"); System.out.println("3 exists in TreeSet ? : " + blnExists); }
From source file:Main.java
public static void main(String[] args) { TreeSet<Integer> tSet = new TreeSet<Integer>(); tSet.add(new Integer("1")); tSet.add(new Integer("2")); tSet.add(new Integer("3")); System.out.println(tSet);/*from w ww . j a v a2 s . c o m*/ System.out.println("Was 2 removed from TreeSet ? " + tSet.remove(new Integer("2"))); System.out.println(tSet); }
From source file:Main.java
public static void main(String[] args) { TreeSet<Integer> tSet = new TreeSet<Integer>(); tSet.add(new Integer("1")); tSet.add(new Integer("2")); tSet.add(new Integer("3")); Object[] objArray = tSet.toArray(); for (Object obj : objArray) { System.out.println(obj);//w w w .j ava 2 s . c o m } }
From source file:Main.java
public static void main(String[] args) { TreeSet<String> tSet = new TreeSet<String>(); tSet.add("1"); tSet.add("2"); tSet.add("3"); tSet.add("4"); tSet.add("5"); System.out.println("Lowest value Stored in Java TreeSet is : " + tSet.first()); System.out.println("Highest value Stored in Java TreeSet is : " + tSet.last()); }
From source file:Main.java
public static void main(String[] args) { TreeSet<Integer> tSet = new TreeSet<Integer>(); tSet.add(new Integer("1")); tSet.add(new Integer("2")); tSet.add(new Integer("3")); System.out.println("TreeSet before removal : " + tSet); tSet.clear();// w w w . ja v a 2 s . co m System.out.println("TreeSet after removal : " + tSet); System.out.println("Is TreeSet empty ? " + tSet.isEmpty()); }
From source file:Main.java
public static void main(String[] args) { TreeSet<Integer> treeadd = new TreeSet<Integer>(); System.out.println(treeadd.isEmpty()); treeadd.add(2);/*from w ww . ja va2 s . c om*/ System.out.println(treeadd.isEmpty()); }
From source file:Main.java
public static void main(String[] args) { TreeSet<Integer> treeadd = new TreeSet<Integer>(); treeadd.add(1);//from ww w .j a v a 2 s.co m treeadd.add(13); treeadd.add(17); treeadd.add(2); System.out.println("Last highest element: " + treeadd.last()); }
From source file:Main.java
public static void main(String[] args) { TreeSet<Integer> treeadd = new TreeSet<Integer>(); treeadd.add(1);/* www. ja va2s . c o m*/ treeadd.add(13); treeadd.add(17); treeadd.add(2); System.out.println("Size of the tree set is: " + treeadd.size()); }
From source file:Main.java
public static void main(String[] args) { TreeSet<Integer> treeadd = new TreeSet<Integer>(); treeadd.add(1);/*from w w w . jav a2 s. c o m*/ treeadd.add(3); treeadd.add(17); treeadd.add(2); System.out.println("Remove 17: " + treeadd.remove(17)); }