A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/java/concurrentskiplistset-isempty-method-in-java/ below:

ConcurrentSkipListSet isEmpty() method in Java

ConcurrentSkipListSet isEmpty() method in Java

Last Updated : 17 Sep, 2018

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
// 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.");
    }
}
Output:
The set is non-empty.
Program 2:

In this program the ConcurrentSkipListSet is empty.

Java
// 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.");
    }
}
Output:
The set is empty.
Reference : https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ConcurrentSkipListSet.html#add(E)

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