Home » Java ConcurrentHashMap put() Method

Java ConcurrentHashMap put() Method

by Online Tutorials Library

Java ConcurrentHashMap put() Method

The put() method of ConcurrentHashMap class maps the specified key to the specified value in this table.

Syntax

Parameter

key – key with which the specified value is to be associated

value – value to be associated with the specified key

Returns

The previous value associated with key, or null if there was no mapping for key

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:

Mappings are: {python=20, c++=30, java=10, c=25, .net=15}  is java  present? ::  true  

You may also like