Sunday, November 23, 2025
HomeLanguagesJavaConcurrentSkipListMap isEmpty() method in Java with Examples

ConcurrentSkipListMap isEmpty() method in Java with Examples

The isEmpty() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which returns boolean value that is it returns true if this map contains no key-value mappings otherwise false.

Syntax:

public boolean isEmpty()

Parameter: The function does not accepts any parameters.

Return Value: The function returns true if this map contains no key-value mappings or else false.

Below programs illustrate the above method:

Program 1:




// Java Program Demonstrate isEmpty()
// method of ConcurrentSkipListMap
  
import java.util.concurrent.*;
  
class GFG {
    public static void main(String[] args)
    {
  
        // Initializing the map
        ConcurrentSkipListMap<Integer, Integer>
            mpp = new ConcurrentSkipListMap<Integer,
                                            Integer>();
  
        // Adding elements to this map
        for (int i = 1; i <= 5; i++)
            mpp.put(i, i);
  
        // checking if map is empty
        System.out.println(mpp.isEmpty());
    }
}


Output:

false

Program 2:




// Java Program Demonstrate isEmpty()
// method of ConcurrentSkipListMap
  
import java.util.concurrent.*;
  
class GFG {
    public static void main(String[] args)
    {
  
        // Initializing the map
        ConcurrentSkipListMap<Integer, Integer>
            mpp = new ConcurrentSkipListMap<Integer,
                                            Integer>();
  
        // checking if map is empty
        System.out.println(mpp.isEmpty());
    }
}


Output:

true

Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentSkipListMap.html#isEmpty–

RELATED ARTICLES

Most Popular

Dominic
32410 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6785 POSTS0 COMMENTS
Nicole Veronica
11932 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12000 POSTS0 COMMENTS
Shaida Kate Naidoo
6909 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6865 POSTS0 COMMENTS
Umr Jansen
6852 POSTS0 COMMENTS