Home » Java ConcurrentHashMap toString() Method

Java ConcurrentHashMap toString() Method

by Online Tutorials Library

Java ConcurrentHashMap toString() Method

The toString() method of ConcurrentHashMap class returns a string representation of this map. The string representation consists of a list of key-value mappings (in no particular order) enclosed in braces (“{}”).

Syntax

Parameter

No parameter is passed.

Returns

a string representation of this map

Throws

No exception is thrown.

Example 1

Test it Now

Output:

HashMap values :   {k1=100, k2=200, k3=300, k4=400}  New HashMap after remove :   {k1=100, k3=300, k4=400}  

Example 2

Test it Now

Output:

mymap2 :{1=101, 2=102, 3=103}   mymap :{AA=Java, BB=angular, CC=JavaScript}  comparing mymap and mymap2 :false  

You may also like