Javatpoint Logo
Javatpoint Logo

Java EnumMap equals() method

The equals() method of Java EnumMap class is used to compare two maps for equality. This method basically compares the passed object with this EnumMap object.

Syntax

Parameters

o - the object to be compared for equality with this map.

Returns

This method returns true if the specified object is equal to this map.

Exception

NA

Example 1

Test it Now

Output:

Map1:{CSS=1, Python=2, PHP=3, Java=4}
Map2:{CSS=1, Python=2, PHP=3, Java=4}
Map1 and Map 2 are equal: true
Map1 and Map 2 are equal: false

Example 2

Test it Now

Output:

Map1:{Monday=1, Tuesday=2, Wednesday=3}
Map2:{Monday=1, Tuesday=2, Wednesday=3}
Map1 and Map 2 are equal: true
Map1 and Map 2 are equal: false
Next TopicJava EnumMap



Please Share

facebook twitter google plus pinterest