Javatpoint Logo
Javatpoint Logo

Java ConcurrentHashMap get() Method

The get() method of ConcurrentHashMap class returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Syntax

Parameter

key - the key whose associated value is to be returned

Returns

the value to which the specified key is mapped, or null if this map contains no mapping for the key

Throws

NullPointerException.

Example 1

Test it Now

Output:

mappings are: {1=AA, 2=BB, 3=CC, 4=DD, 5=EE}
 Value : null
 Value : DD

Example 2

Test it Now

Output:

mappings are: {A1=AA, A2=BB, A3=CC, A4=DD, A5=EE}
 Value : AA
 Value : EE





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