Open In App

EnumMap clear() Method in Java with Examples

Last Updated : 11 Jul, 2018
Comments
Improve
Suggest changes
Like Article
Like
Report
The Java.util.EnumMap.clear() method in Java is used to remove all the mappings from the map. The method does not delete the map instead it just clears the map of the mappings. Syntax:
enum_map.clear()
Parameters: This method does not accept any argument. Return Values: This method does not return any value. Below programs illustrate the working of Java.util.EnumMap.clear() method: Program 1:
Output:
Values in map before removing {Global=800, India=72}
Values in map after removing {}
Program 2:
Output:
Values in map before removing {Orange=30, Apple=50, Banana=40, 
                                    Pomegranate=120, Guava=20}
Values in map after removing {}

Practice Tags :

Similar Reads