Javatpoint Logo
Javatpoint Logo

Java EnumMap putAll() method

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

Test it Now

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

Test it Now

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}
Next TopicJava EnumMap



Please Share

facebook twitter google plus pinterest