Java TreeSet ceiling() methodThe ceiling() is a method of TreeSet class which is used to find element which is greater than or equal to the given element in the argument list. Syntax:Specified by:ceiling in interface NavigableSet<E> : In this, the NavigableSet returns the element which is greater than or equal to the given element. Parameter:e - element to match Return:It returns true if the value is greater than or equal to the value in the set else it returns false. Throws:ClassCastException: Throws exception when typecasting is performed in the elements of Set and they are not compatible with each other. NullPointerException: Throws exception when Set elements are null. Example 1Output: TreeSet: [ 1, 2, 5, 8, 10 ] Ceiling value of 4 in set: 5 Example 2Output: TreeSet: [ ALL, BOB, acer, bill ] Ceiling value of bi in set: bill Example 3Output: TreeSet: [1, 3, 6, 7] Ceiling value of 4 in set: 6 Ceiling value of 10 in set: null Next TopicJava-treeset-clear-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India