The java.util.TreeSet.tailSet() method is used to set a point of start for a tree set, to return all the elements greater than the element passed as parameter mentioned to the method in a sorted manner including the element(if the element is mentioned in the tree).
TreeSet tail_set.tailSet(Object element)
Parameters: The parameter element is of the type of the TreeSet and is the start point from which the tree is allowed to return the values greater than the value mentioned in the parameter including the element.
Return Values: The method returns the portion of the values in a sorted manner that is greater than the element mentioned in the parameter, including the parameter.
Below programs illustrate the use of java.util.TreeSet.tailSet():
Program 1: In a sorted TreeSet.
The resultant values from the tail: 10 20 30 40 50
Program 2: In an unsorted TreeSet.
The resultant values from the tail: 30 40 50 100
Program 3: In an unsorted TreeSet but with String type elements.
The resultant values from the tail: To TreeSet Welcome
- SortedSet tailSet() method in Java
- ConcurrentSkipListSet tailSet() method in Java with Examples
- TreeSet add() Method in Java
- TreeSet first() Method in Java
- TreeSet contains() Method in Java
- TreeSet last() Method in Java
- TreeSet size() Method in Java
- TreeSet toString() method in Java with Example
- TreeSet remove() Method in Java
- TreeSet headSet() Method in Java
- TreeSet retainAll() method in Java with Example
- TreeSet toArray() method in Java with Example
- TreeSet pollFirst() method in Java
- TreeSet lower() method in Java
- TreeSet subSet() Method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.