The java.util.IdentityHashMap.equals() method in Java is used to check for equality between two maps. It verifies whether the elements of one map passed as a parameter is equal to the elements of this map or not.
Syntax: ihashmap1.equals(ihashmap2)
Parameters: The method accepts one parameter
ihashmap2 of identity hash map type and refers to the map whose equality is to be checked with this hash map.
Return Value: The method returns true if the equality holds for both the object map else it returns false.
Below programs illustrate the working of java.util.IdentityHashMap.equals() method:
Program 1:
Output:
First Map: {10=Geeks, 30=You, 20=Geeks, 25=Welcomes, 15=4}
Second Map: {10=Geeks, 30=You, 20=Geeks, 25=Welcomes, 15=4}
Equality: true
Program 2:
Output:
First Map: {10=Geeks, 30=You, 20=Geeks, 25=Welcomes, 15=4}
Second Map: {10=Geeks, 30=You, 20=Geek, 25=Welcomes, 15=4}
Equality: false