Javatpoint Logo
Javatpoint Logo

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

Test it Now

Output:

Id is : 8888  JavaTpoint





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA