92
Java ConcurrentHashMap clear() Method
The clear() method of Constructor class removes all of the mappings from this map.
Syntax
Parameter
No any parameter is passed.
Returns
NA
Throws
No exception is thrown.
Example 1
Output:
Values in map: {1=1, 2=10, 3=100, 4=2, 5=20, 6=200} Map after calling clear(): {}
Example 2
Output:
Values in map: {a=1, b=10, c=100, d=2, e=20, f=200} Map after calling clear(): {}
Next TopicJava ConcurrentHashMap