How get Tail set from TreeSet

How get Tail set from TreeSet

Previous Home Next

 

This program will show how to get Tail set from TreeSet. TailSet will return the value equal to , and greater than the the to value.

TailSet is a method which is used to return the value from the TreesSet. equal to and greater than the to value .
 TailSet is a method which is used to return the value from the TreesSet. equal to and greater than the to value .

TailSet is a method which is used to return the value from the TreesSet. equal to and greater than the to value .

 

package Example;

import java.util.Iterator;
import java.util.TreeSet;
import java.util.SortedSet;

public class TreeSetTailSet {

/**
* @param args
*/
public static void main(String[] args) {
TreeSet Tst =new TreeSet();
Tst.add(new Integer("10"));
Tst.add(new Integer("17"));
Tst.add(new Integer("15"));
Tst.add(new Integer("19"));
Tst.add(new Integer("12"));
Tst.add(new Integer("13"));

SortedSet sortedSet = Tst.tailSet(new Integer ("12"));

System.out.println("TailSet Contains : " + sortedSet);

// TODO Auto-generated method stub

}

}

Tail set Contains : [12, 13, 15, 17, 19]

Previous Home Next