Home » Java ConcurrentHashMap clear() Method

Java ConcurrentHashMap clear() Method

by Online Tutorials Library

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

Test it Now

Output:

Values in map:   {1=1, 2=10, 3=100, 4=2, 5=20, 6=200}  Map after calling clear(): {}  

Example 2

Test it Now

Output:

Values in map:   {a=1, b=10, c=100, d=2, e=20, f=200}  Map after calling clear(): {}  

You may also like