97
Java ConcurrentHashMap getOrDefault() Method
The getOrDefault() method of ConcurrentHashMap class returns the value to which the specified key is mapped, or the given default value if this map contains no mapping for the key.
Syntax
Parameter
key – the key whose associated value is to be returned
defaultValue – the value to return if this map contains no mapping for the given key
Returns
the mapping for the key, if present; else the default value
Throws
NullPointerException
Example 1
Output:
Id is : 8888 TutorAspire
Next TopicJava ConcurrentHashMap