ConcurrentSkipListSet tailSet() method in Java with Examples Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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.Syntax: tailSet(E fromElement) or tailSet(E fromElement, boolean inclusive) Parameters: 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.Returns: 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.Exception: Null Pointer Exception: if the specified element is NULL.Below are the sample programs to illustrate ConcurrentSkipListSet tailSet() in Java:Example: 1 The elements which are greater than 200 are returned. Java // Java program to demonstrate ConcurrentSkipListSet tailSet() method import java.util.concurrent.ConcurrentSkipListSet; class ConcurrentSkipListSetLastExample1 { public static void main(String[] args) { // Initializing the set using ConcurrentSkipListSet() ConcurrentSkipListSet<Integer> set = new ConcurrentSkipListSet<Integer>(); // Adding elements to this set set.add(199); set.add(256); set.add(958); set.add(421); set.add(80); // Printing the ConcurrentSkipListSet System.out.println("ConcurrentSkipListSet: " + set); // Printing the elements of ConcurrentSkipListSet that // are returned by tailSet() method System.out.println("The returned elements are: " + set.tailSet(200)); } } Output: ConcurrentSkipListSet: [80, 199, 256, 421, 958] The returned elements are: [256, 421, 958] Example: 2 In this example, the element 35 is not returned because boolean inclusive is false. Java // Java program to demonstrate ConcurrentSkipListSet tailSet() method import java.util.concurrent.ConcurrentSkipListSet; class ConcurrentSkipListSetLastExample1 { public static void main(String[] args) { // Initializing the set using ConcurrentSkipListSet() ConcurrentSkipListSet<Integer> set = new ConcurrentSkipListSet<Integer>(); // Adding elements to this set set.add(13); set.add(35); set.add(9); set.add(41); set.add(90); // Printing the ConcurrentSkipListSet System.out.println("ConcurrentSkipListSet: " + set); // Printing the elements of ConcurrentSkipListSet that // are returned by tailSet() method System.out.println("The returned elements are: " + set.tailSet(35, false)); } } Output: ConcurrentSkipListSet: [9, 13, 35, 41, 90] The returned elements are: [41, 90] Comment More infoAdvertise with us Next Article ConcurrentSkipListSet equals() method in Java P ProgrammerAnvesh Follow Improve Article Tags : Java Java-Collections Java - util package Java-Functions Java-ConcurrentSkipListSet +1 More Practice Tags : JavaJava-Collections Similar Reads ConcurrentSkipListSet subSet() method in Java with Examples The subSet() method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java where the elements are returned in a range defined by this method. The syntax of the function gives a clear understanding of the specified element followed by the examples.Syntax: subSet(E fromElement, 2 min read ConcurrentSkipListSet lower() method in Java with Examples The lower() method of ConcurrentSkipListSet is used to return the largest element present in this set which is strictly less than the specified element. If there is no such element present in the set, then this function will return null. Syntax: public E lower (E e) Parameters: This method takes onl 2 min read ConcurrentSkipListSet comparator() method in Java with Examples The comparator() method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java which returns the comparator used for ordering the elements in the given set. If natural ordering is used, null is returned. Syntax: public Comparator<E> comparator() Here E is the type parame 2 min read ConcurrentSkipListSet equals() method in Java The equals() method of java.util.concurrent.ConcurrentSkipListSet is an inbuilt function in Java which compares the specified object with this set for equality. It returns True if the specified object is also a set. The two sets will said to be equal if they satisfies all of the conditions stated be 3 min read ConcurrentHashMap entrySet() method in Java with Examples The entrySet() method of ConcurrentHashMap in Java is used to create a set from the same elements contained in the concurrent hash map. It basically returns a set view of the concurrent hash map or we can create a new set and store the map elements into them. Syntax: ConcurrentHashMap.entrySet() Par 2 min read ConcurrentSkipListSet subSet() method in Java subSet(E fromElement, E toElement) The subSet() method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java which returns a view of the portion of this set whose elements range from fromElement, inclusive, to toElement, exclusive. (If fromElement and toElement are equal, the 5 min read Like