Javatpoint Logo
Javatpoint Logo

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(): {}





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA