TreeSet ceiling method examples

TreeSet ceiling method returns the closest element greater than or equal to the given element.

e – the value to match
the least element greater than or equal to e, or null if there is no such element
ClassCastException – if the specified element cannot be compared with the elements currently in the set
NullPointerException – if the specified element is null and this set uses natural ordering, or its comparator does not permit null elements

TreeSet ceiling method Example

In the below example we will see various scenarios in which ceiling method works.


TreeSet ceiling method


1. TreeSet ceiling method java docs