VOOZH about

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

⇱ ConcurrentSkipListSet ceiling() method in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

ConcurrentSkipListSet ceiling() method in Java

Last Updated : 17 Sep, 2018
The java.util.concurrent.ConcurrentSkipListSet.ceiling() method is an in-built function in Java which returns the least element in this set greater than or equal to the given element, or null if there is no such element. Syntax:
 ConcurrentSkipListSet.ceiling(E e)
Parameters: The function accepts a single parameter e i.e. the element to match. Return Value: The function returns the least element greater than or equal to e, or null if there is no such element. Exception: The function shows 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.ceiling() method: Program 1: To find ceiling of a number.
    Output:
    The set contains: 
    13 31 45 72 89 
    Ceiling of 35: 45
    
    Ceiling of 100: null
    
    Program 2: To show NullPointerException in ceiling().
    Comment