Open In App

ConcurrentSkipListMap containsValue() method in Java with Examples

Last Updated : 30 Sep, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

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-
 



Similar Reads

ConcurrentSkipListMap clone() method in Java with Examples
The clone() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which returns a shallow copy of this ConcurrentSkipListMap instance. The keys and values themselves are not cloned. Syntax: ConcurrentSkipListMap.clone() Parameter: The function does not accept any parameter. Parameter: This method do not accepts any pa
2 min read
ConcurrentSkipListMap containsKey() method in Java with Examples
The containsKey() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which returns a true boolean value if the specified element is present in this map otherwise it returns false. Syntax: public boolean containsKey(Object ob) Parameter: The function accepts a single mandatory parameter ob which specifies the key wh
2 min read
ConcurrentSkipListMap put() method in Java with Examples
The put() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced. Syntax: public V put(K key, V value) Parameter: The function accepts two mandatory parameters: key w
2 min read
ConcurrentSkipListMap equals() method in Java with Examples
The equals() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which to check the equality of this Map object with the specified object. The method returns true if the given object is also a map of the previous one and the two maps have the same mappings. Syntax: public boolean equals(Object ob) Parameter: The fun
2 min read
ConcurrentSkipListMap ceilingKey() method in Java with Examples
The ceilingKey() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which returns the least key greater than or equal to the given key. If there is no such value then null is returned. The method throws NullPointerException when there is no key. Syntax: public K ceilingKey(K key) Parameter: The function accepts a s
2 min read
ConcurrentSkipListMap remove() method in Java with Examples
The remove() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which removes the mapping for the specified key from this map. The method returns null if there is no mapping for of that particular key. After this method is performed the size of the map is reduced. Syntax: ConcurrentSkipListMap.remove(Object ob) Par
2 min read
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 m
1 min read
ConcurrentSkipListMap size() method in Java with Examples
The size() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which that is it returns the number of keys mapped to this map. The size() method is not a constant time operation. In case the map contains more than Integer.MAX_VALUE elements, the maximum value of the map is returned. Syntax: public int size() Paramet
2 min read
ConcurrentSkipListMap clear() method in Java with Examples
The clear() method of java.util.concurrent.ConcurrentSkipListMap is an in-built function in Java which removes all of the mappings from this map. This means that all the elements from the map are removed and an empty map is returned. Syntax: public void clear() Parameter: The function does not accepts any parameters. Return Value: The function remo
2 min read
ConcurrentSkipListMap in Java with Examples
The ConcurrentSkipListMap class is a member of the Java Collections Framework. It was introduced in JDK 1.6, it belongs to java.util.concurrent package. The ConcurrentSkipListMap is a scalable implementation of ConcurrentNavigableMap. All the elements are sorted based on natural ordering or by the Comparator passed during it's construction time. Th
10 min read