ConcurrentSkipListSet floor() method in Java Last Updated : 21 Sep, 2018 Comments Improve Suggest changes Like Article Like Report 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 single parameter e i.e. the value to match. Return Value: The function returns the greatest element less than or equal to 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.floor() method: Program 1: Java // Java program to demonstrate floor() // method of ConcurrentSkipListSet import java.util.concurrent.*; class ConcurrentSkipListSetFloorExample1 { 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 floor of 20 in the set System.out.println("The floor of 20 in the set " + Lset.floor(20)); // Finding floor of 39 in the set System.out.println("The floor of 39 in the set " + Lset.floor(39)); // Finding floor of 9 in the set System.out.println("The floor of 10 in the set " + Lset.floor(9)); } } Output: The floor of 20 in the set 20 The floor of 39 in the set 30 The floor of 10 in the set null Program 2: Program to show NullPointerException in floor(). Java // Java program to demonstrate floor() // method of ConcurrentSkipListSet import java.util.concurrent.*; class ConcurrentSkipListSetFloorExample2 { 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); // Trying to find the floor of null try { System.out.println("The floor of null in the set " + Lset.floor(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#floor-E- Create Quiz Comment R rupesh_rao Follow 0 Improve R rupesh_rao Follow 0 Improve Article Tags : Misc Java Java - util package Java-Functions Java-ConcurrentSkipListSet +1 More Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings7 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java5 min readAccess Modifiers in Java4 min readJava Constructors4 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages2 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java4 min readJava Comparator Interface5 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java7 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management3 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read Like