Java EnumMap clone() methodLast Updated : 17 Mar 2025 The clone() method of Java EnumMap class is used to copy the mapped value of one map to another map. This method creates a shallow copy of this map. SyntaxParametersNA ReturnsThis method returns a shallow copy of this enum map. ExceptionNA Basic SyntaxEnumMapTwo=EnumMapOne.clone(); Example 1Output: Values of map before cloning:
map1:{ Java=1, Python=2, PHP=3, Android=4, AngularJS=5}
map2:{}
Values of map after cloning:
map1:{ Java=1, Python=2, PHP=3, Android=4, AngularJS=5}
map2:{ Java=1, Python=2, PHP=3, Android=4, AngularJS=5}
Example 2Output: Values of map before cloning:
map1:{Monday=1, Tuesday=2, Wednesday=3, Thursday=4}
map2:{}
Values of map after cloning:
map1:{Monday=1, Tuesday=2, Wednesday=3, Thursday=4}
map2:{Monday=1, Tuesday=2, Wednesday=3, Thursday=4}
Next TopicJava-enummap-containskey-method |
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India