ConcurrentSkipListSet isEmpty() method in Java
The java.util.concurrent.ConcurrentSkipListSet.isEmpty() method is an in-built function in Java which is used to check if this set is empty or not.
Syntax:
ConcurrentSkipListSet.isEmpty()
Parameters: The function does not accepts any parameter.
Return Value: The function returns a boolean value. It returns true if the ConcurrentSkipListSet is empty and returns false otherwise.
Below programs illustrate the ConcurrentSkipListSet.IsEmpty() method:
Program 1: In this program the ConcurrentSkipListSet is non-empty.
// Java Program to demonstrate isEmpty() // method of ConcurrentSkipListSet() import java.util.concurrent.*; class ConcurrentSkipListSetIsEmptyExample1 { 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); // Checks if this set is empty or not if (Lset.isEmpty()) System.out.println("The set is empty."); else System.out.println("The set is non-empty."); } } |
The set is non-empty.
Program 2: In this program the ConcurrentSkipListSet is empty.
// Java program to demonstrate isEmpty() // method of ConcurrentSkipListSet() import java.util.concurrent.*; class ConcurrentSkipListSetIsEmptyExample2 { public static void main(String[] args) { // Creating a set object ConcurrentSkipListSet<Integer> Lset = new ConcurrentSkipListSet<Integer>(); // Checks if this set is empty or not if (Lset.isEmpty()) System.out.println("The set is empty."); else System.out.println("The set is non-empty."); } } |
The set is empty.
Reference : https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ConcurrentSkipListSet.html#add(E)
Recommended Posts:
- ConcurrentSkipListSet contains() method in Java
- ConcurrentSkipListSet last() method in Java
- ConcurrentSkipListSet add() method in Java
- ConcurrentSkipListSet first() method in Java
- ConcurrentSkipListSet equals() method in Java
- ConcurrentSkipListSet descendingSet() method in Java
- ConcurrentSkipListSet subSet() method in Java
- ConcurrentSkipListSet removeAll() method in Java
- ConcurrentSkipListSet remove() method in Java
- ConcurrentSkipListSet descendingIterator() method in Java
- ConcurrentSkipListSet iterator() method in Java
- ConcurrentSkipListSet ceiling() method in Java
- ConcurrentSkipListSet spliterator() method in Java
- ConcurrentSkipListSet clear() method in Java
- ConcurrentSkipListSet size() method in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



