1import java.util.Iterator;
2import java.util.TreeSet;
3public class TreeSetTailSetFromElementMethod
4{
5 public static void main(String[] args)
6 {
7 TreeSet<Integer> ts = new TreeSet<Integer>();
8 TreeSet<Integer> inclusive = new TreeSet<Integer>();
9 ts.add(12);
10 ts.add(22);
11 ts.add(32);
12 ts.add(42);
13 ts.add(52);
14 ts.add(62);
15 ts.add(72);
16 ts.add(82);
17 // create tailSet
18 inclusive = (TreeSet)ts.tailSet(52, true);
19 // create iterator
20 Iterator<Integer> iterate = inclusive.iterator();
21 System.out.println("TreeSet tailSet: ");
22 while(iterate.hasNext())
23 {
24 System.out.println(iterate.next() + " ");
25 }
26 }
27}
28
29
30