Last Updated : 11 Jul, 2025
The
lower()method of
ConcurrentSkipListSetis used to return the largest element present in this set which is
strictlyless than the specified element. If there is no such element present in the set, then this function will return null.
Syntax:public E lower (E e)Parameters:
This method takes only one parameter,
ewhich is the specified value to be matched.
Return Value:This method returns
a valuewhich is the largest element present in the set which is strictly less the specified element. If no such element is present, then it will return Null.
Exceptions:This method throws following exceptions:
Below program illustrates the lower() function of ConcurrentSkipListSet class:
Program 1:In the below program, the specified element is 67, our set also contains the element 67, but it is not returned because lower() method returns strictly less value.
Java
// Java program to demonstrate
// ConcurrentSkipListSet lower() method.
import java.util.concurrent.ConcurrentSkipListSet;
class GfgCSLS {
public static void main(String[] args)
{
// Initializing the set
// using ConcurrentSkipListSet()
ConcurrentSkipListSet<Integer>
set = new ConcurrentSkipListSet<Integer>();
// Adding elements to this set
// using add() method
set.add(17);
set.add(24);
set.add(35);
set.add(67);
set.add(98);
// Printing the ConcurrentSkipListSet
System.out.println("ConcurrentSkipListSet: "
+ set);
// Invoking lower() method
// to find the largest element
// less than the specified element
System.out.println("Largest element: "
+ set.lower(67));
}
}
Output:
ConcurrentSkipListSet: [17, 24, 35, 67, 98] Largest element: 35Program 2:
To show NullpointerException
Java
// Java program to demonstrate
// ConcurrentSkipListSet lower() method.
import java.util.concurrent.ConcurrentSkipListSet;
class GfgCSLS {
public static void main(String[] args)
{
// Initializing the set
// using ConcurrentSkipListSet()
ConcurrentSkipListSet<Integer>
set = new ConcurrentSkipListSet<Integer>();
// Adding elements to this set
// using add() method
set.add(17);
set.add(24);
set.add(35);
set.add(67);
set.add(98);
// Printing the ConcurrentSkipListSet
System.out.println("ConcurrentSkipListSet: "
+ set);
try {
// Invoking lower() method
// to find the largest element
// less than the specified element
System.out.println("Largest element: "
+ set.lower(null));
}
catch (Exception e) {
System.out.println(e);
}
}
}
Output:
ConcurrentSkipListSet: [17, 24, 35, 67, 98] java.lang.NullPointerException
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4