VOOZH about

URL: https://www.geeksforgeeks.org/java/concurrentskiplistset-higher-method-in-java/

⇱ ConcurrentSkipListSet higher() method in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

ConcurrentSkipListSet higher() method in Java

Last Updated : 21 Sep, 2018
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:
    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().
    Comment