Friday, November 21, 2025
HomeLanguagesJavaConcurrentSkipListMap containsValue() method in Java with Examples

ConcurrentSkipListMap containsValue() method in Java with Examples

The containsValue() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which returns true if this map maps one or more keys to the specified value. The method returns null if there is no key to be mapped. The method throws NullPointerException when the specified value is null.
Syntax: 
 

public boolean containsValue(Object ob)

Parameter: The function accepts a single mandatory parameter ob which specifies the value whose presence is to be tested.
Return Value: The function returns true if mapping exists or else returns false.
Exception: The method throws NullPointerException when the specified value is null.
Below programs illustrate the above method:
Program 1: 
 

Java




// Java Program Demonstrate containsValue()
// 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 whether object present in map
        System.out.println(mpp.containsValue(4));
    }
}


Output: 

true

 

Program : 
 

Java




// Java Program Demonstrate containsValue()
// 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 whether object present in map
        System.out.println(mpp.containsValue(7));
    }
}


Output: 

false

 

Reference: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ConcurrentSkipListMap.html#containsValue-java.lang.Object-
 

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32405 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6781 POSTS0 COMMENTS
Nicole Veronica
11928 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11997 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7166 POSTS0 COMMENTS
Thapelo Manthata
6862 POSTS0 COMMENTS
Umr Jansen
6847 POSTS0 COMMENTS