The java.util.concurrent.ConcurrentHashMap.containsValue() method is an in-built function in Java which accepts a value and returns true if one or more keys are mapped to the specified value. This method traverses the entire hashtable. Thus it is a much slower function than containsKey() method.
Parameters: The method accepts a single parameter val_element of object type which is to be checked for whether it is mapped to any key in the map or not.
Return Value: The method returns true if the specified val_element is mapped to any key in this map and false otherwise.
Exception: The function throws NullPointerException when the specified value_element is null.
Below programs illustrate the use of java.util.concurrent.ConcurrentHashMap.containsValue() method :
Program 1: This program involves mapping Integer Values to String Keys.
100 is not mapped. 120 is mapped.
Program 2: This program involves mapping String Values to Integer Keys.
Geeks is mapped. GfG is not mapped.
- Map containsValue() method in Java with Examples
- HashMap containsValue() Method in Java
- IdentityHashMap containsValue() Method in Java
- TreeMap containsValue() Method in Java
- EnumMap containsValue(value) method in Java
- WeakHashMap containsValue() Method in Java
- Hashtable containsValue() Method in Java
- ConcurrentSkipListMap containsValue() method in Java with Examples
- Properties containsValue(value) method in Java with Examples
- AbstractMap containsValue() Method in Java with Examples
- ConcurrentHashMap get() Method in Java
- ConcurrentHashMap put() method in Java
- ConcurrentHashMap putIfAbsent() Method in Java
- ConcurrentHashMap remove() method in Java
- ConcurrentHashMap containsKey() 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 email@example.com. 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.