The tailSet() method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java where the elements which are equal to or greater than the specified element are returned.
The syntax of the function gives a clear understanding of the specified element followed by the examples.
tailSet(E fromElement) or tailSet(E fromElement, boolean inclusive)
The first variation of this method takes only one parameter, i.e. the fromElement E from where the elements which are greater than or equal to this element are returned from the set.
The second variation is similar to the first one but here the second parameter is boolean inclusive if it is set to false
then the element E (if present in the list) will not be included.
This method returns a view of the portion of this set whose elements are greater than or equal to fromElement.
In the case of the second variation, the inclusion of this fromElement is decided by boolean type.
Null Pointer Exception: if the specified element is NULL.
Below are the sample programs to illustrate ConcurrentSkipListSet tailSet() in Java:
The elements which are greater than 200 are returned.
ConcurrentSkipListSet: [80, 199, 256, 421, 958] The returned elements are: [256, 421, 958]
In this example, the element 35 is not returned because boolean inclusive is false.
ConcurrentSkipListSet: [9, 13, 35, 41, 90] The returned elements are: [41, 90]
- ConcurrentSkipListSet subSet() method in Java with Examples
- ConcurrentSkipListSet lower() method in Java with Examples
- ConcurrentSkipListSet comparator() method in Java with Examples
- SortedSet tailSet() method in Java
- TreeSet tailSet() Method in Java
- ConcurrentSkipListSet in Java with Examples
- ConcurrentSkipListSet add() method in Java
- ConcurrentSkipListSet contains() method in Java
- ConcurrentSkipListSet first() method in Java
- ConcurrentSkipListSet last() method in Java
- ConcurrentSkipListSet removeAll() method in Java
- ConcurrentSkipListSet ceiling() method in Java
- ConcurrentSkipListSet headSet() method in Java
- ConcurrentSkipListSet iterator() method in Java
- ConcurrentSkipListSet higher() 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 firstname.lastname@example.org. 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.