Home » Java ConcurrentHashMap containsValue() Method

Java ConcurrentHashMap containsValue() Method

by Online Tutorials Library

Java ConcurrentHashMap containsValue() Method

The containsValue() method of ConcurrentHashMap class returns true if this map maps one or more keys to the specified value. Note: This method may require a full traversal of the map, and is much slower than method containsKey.

Syntax

Parameter

value – value whose presence in this map is to be tested

Returns

true if this map maps one or more keys to the specified value

Throws

NullPointerException

Example 1

Test it Now

Output:

Mappings are: {AAA=10, CCC=25, BBB=15, EEE=30, DDD=255}  is 255  present? ::  true  

Example 2

Test it Now

Output:

ConcurrentHashMap values :   {A=26, B=98, C=55}  new ConcurrentHashMap after  computeIfPresent :   {A=26, B=98, C=155}   is 98 is present  :   true  

You may also like