Open In App

EnumMap clone() Method in Java

Last Updated : 24 Jul, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
The Java.util.EnumMap.clone() method in Java is used to copy the mapped values of one map to another. It basically creates a shallow copy of this map. Syntax:
Enum_map_2 = Enum_map_1.clone()
Parameters: The method does not accept any argument. Return Value: The method returns a shallow copy of a EnumMap. Below programs illustrate the Java.util.EnumMap.clone() method Program 1:
Output:
Price of fruits in 1st map {Orange=30, Apple=60, Banana=40, Pomegranate=120, Guava=20}
Price of fruits in 2nd map {Orange=30, Apple=60, Banana=40, Pomegranate=120, Guava=20}
Program 2:
Output:
GeeksforGeeks ranking in first map {Global_2018=800, India_2018=72}
GeeksforGeeks ranking in second map {Global_2018=800, India_2018=72}

Next Article

Similar Reads