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 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 onject present in map System.out.println(mpp.containsValue(4)); } } |
true
Program :
// 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 onject present in map System.out.println(mpp.containsValue(7)); } } |
false
Recommended Posts:
- ConcurrentSkipListMap put() method in Java with Examples
- ConcurrentSkipListMap clear() method in Java with Examples
- ConcurrentSkipListMap isEmpty() method in Java with Examples
- ConcurrentSkipListMap ceilingKey() method in Java with Examples
- ConcurrentSkipListMap clone() method in Java with Examples
- ConcurrentSkipListMap containsKey() method in Java with Examples
- ConcurrentSkipListMap size() method in Java with Examples
- ConcurrentSkipListMap remove() method in Java with Examples
- ConcurrentSkipListMap equals() method in Java with Examples
- Map containsValue() method in Java with Examples
- Properties containsValue(value) method in Java with Examples
- AbstractMap containsValue() Method in Java with Examples
- Hashtable containsValue() Method in Java
- EnumMap containsValue(value) method in Java
- HashMap containsValue() 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.



