Java examples for Collection Framework:TreeSet
To get a Tail Set from Java TreeSet use, SortedSet tailSet(Object fromElement) method of Java TreeSet class.
import java.util.SortedSet; import java.util.TreeSet; public class Main { public static void main(String[] args) { TreeSet tSet = new TreeSet(); //from w ww . ja va 2 s.com //add elements to TreeSet tSet.add("1"); tSet.add("3"); tSet.add("2"); tSet.add("5"); tSet.add("4"); SortedSet sortedSet = tSet.tailSet("2"); System.out.println("Tail Set Contains : " + sortedSet); } }