ConcurrentSkipListSet higher() method in Java Last Updated : 21 Sep, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The higher(E e) method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java which returns the least element in this set strictly greater than the given element, or null if there is no such element. Syntax: public E higher(E e) Parameter: The function accepts a single parameter e i.e the value to match Return Value: The function returns the least element greater than e, or null if there is no such element. Exception: The function throws the following exceptions: ClassCastException - if the specified element cannot be compared with the elements currently in the set. NullPointerException - if the specified element is null Below programs illustrate the ConcurrentSkipListSet.higher(E e) method: Program 1: Java // Java program to demonstrate higher() // method of ConcurrentSkipListSet import java.util.concurrent.*; class ConcurrentSkipListSetHigherExample1 { public static void main(String[] args) { // Creating a set object ConcurrentSkipListSet<Integer> Lset = new ConcurrentSkipListSet<Integer>(); // Adding elements to this set for (int i = 10; i <= 50; i += 10) Lset.add(i); // Finding higher of 20 in the set System.out.println("The higher of 20 in the set: " + Lset.higher(20)); // Finding higher of 39 in the set System.out.println("The higher of 39 in the set: " + Lset.higher(39)); // Finding higher of 50 in the set System.out.println("The higher of 50 in the set: " + Lset.higher(50)); } } Output: The higher of 20 in the set: 30 The higher of 39 in the set: 40 The higher of 50 in the set: null Program 2: Program to show NullPointerException in higher(). Java // Java program to demonstrate higher() // method of ConcurrentSkipListSet import java.util.concurrent.*; class ConcurrentSkipListSetHigherExample1 { public static void main(String[] args) { // Creating a set object ConcurrentSkipListSet<Integer> Lset = new ConcurrentSkipListSet<Integer>(); // Adding elements to this set for (int i = 10; i <= 50; i += 10) Lset.add(i); try { // Trying to find higher of "null" in the set System.out.println("The higher of null in the set: " + Lset.higher(null)); } catch (Exception e) { System.out.println("Exception: " + e); } } } Output: Exception: java.lang.NullPointerException Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentSkipListSet.html#higher-E- Comment More infoAdvertise with us Next Article ConcurrentSkipListSet add() method in Java R rupesh_rao Follow Improve Article Tags : Misc Java Java - util package Java-Functions Java-ConcurrentSkipListSet +1 More Practice Tags : JavaMisc Similar Reads ConcurrentSkipListSet first() method in Java The first() method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java which returns the first (lowest) element currently in this set. Syntax: ConcurrentSkipListSet.first() Return Value: The function returns the first (lowest) element currently in this set. Exception: The f 1 min read ConcurrentSkipListSet headSet() method in Java headSet(E toElement) The java.util.concurrent.ConcurrentSkipListSet.headSet() method is an in-built function in Java which returns a view of the portion of this set whose elements are strictly less than toElement. The returned set is backed by this set, so changes in the returned set are reflected i 4 min read ConcurrentSkipListSet floor() method in Java The floor() method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java which returns the greatest element in this set less than or equal to the given element, or null if there is no such element. Syntax: ConcurrentSkipListSet.floor(E e) Parameter: The function accepts a sin 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 ConcurrentSkipListSet add() method in Java The java.util.concurrent.ConcurrentSkipListSet.add() method is an in-built function in Java which is used to insert an element in this set. Syntax: ConcurrentSkipListSet.add(E e) Parameters: The function accepts a single parameter e i.e. the element to be inserted. Return Value: The function returns 2 min read ConcurrentSkipListSet descendingSet() method in Java The descendingSet() method of java.util.concurrent.ConcurrentSkipListSet is an in-built function in Java which returns a reverse order view of the elements contained in this set. The descending set is backed by this set, so changes to the set are reflected in the descending set, and vice-versa. Synt 2 min read Like