Home » Java ConcurrentHashMap putAll() Method

Java ConcurrentHashMap putAll() Method

by Online Tutorials Library

Java ConcurrentHashMap putAll() Method

The putAll() method of ConcurrentHashMap class copies all of the mappings from the specified map to this one. These mappings replace any mappings that this map had for any of the keys currently in the specified map.

Syntax

Parameter

m – mappings to be stored in this map

Returns

Have void as return type.

Throws

No exception is thrown.

Example 1

Test it Now

Output:

Mappings : {100=AAA, 101=BBB, 102=CCC, 103=DDD, 104=EEE}  New mappings : {100=AAA, 101=BBB, 102=CCC, 103=DDD, 104=EEE}  

Example 2

Test it Now

Output:

Mappings : {K1=AAA, K2=BBB, K3=CCC, K4=DDD, K5=EEE}  New mappings : {K1=AAA, K2=BBB, K3=CCC, K4=DDD, K5=EEE}  

You may also like