Java EnumMap putAll() method
Last Updated : 17 Mar 2025
The putAll() method of Java EnumMap class is used to copy all the mappings from one EnumMap to a new EnumMap.
Syntax
Parameters
m - the map which is to be copied to the newer one.
Returns
This method does not return any value.
Exception
NullPointerException - if the given map is null, or if one or more keys in the given map are null.
Example 1
Output:
Map1: {Monday=1, Tuesday=2, Wednesday=3}
Map2: {}
Map1: {Monday=1, Tuesday=2, Wednesday=3}
Map2: {Monday=1, Tuesday=2, Wednesday=3}
Example 2
Output:
Map1: {Java=1, CSS=2, Python=3, Android=4}
Map2: {}
Map1: {Java=1, CSS=2, Python=3, Android=4}
Map2: {Java=1, CSS=2, Python=3, Android=4}