Javatpoint Logo
Javatpoint Logo

Java EnumMap clear() method

The clear() method of Java EnumMap class is used to clear all the mapping from the map. This method does not remove the map instead it just removes all the entry from the map.

Syntax

Parameters

NA

Returns

This method does not return any value.

Exception

NA

Example 1

Test it Now

Output:

Values in map before removing:
{Java=1, Python=2, PHP=3, Android=4, AngularJS=5}
Values in map after removing:
{}

Example 2

Test it Now

Output:

Values in map before removing:
{Monday=1, Tuesday=2, Wednesday=3, Thursday=4}
Values in map after removing:
{}
Next TopicJava EnumMap



Please Share

facebook twitter google plus pinterest