Java AbstractMap equals() Method Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The equals() method of the Java AbstractMap class is used to check equality between two maps. It compares the key-value pair in the current map with the key-value pair of the specified map.Syntax of AbstarctMap equals() Methodpublic boolean equals(Object o)Parameter: The Object to be compared with the current map.Return Type: Return "true" if the specified object is equal to the current map, otherwise return "false".Example: This example demonstrates how the equals() method checks for equality between different HashMap instances based on their key-value mapping. Java // Java code to demonstrate the working of equals() import java.util.AbstractMap; import java.util.HashMap; import java.util.Map; public class Geeks { public static void main(String[] args) { // Creating three HashMap instances Map<String, Integer> hm1 = new HashMap<>(); hm1.put("Geek1", 1); hm1.put("Geek2", 2); hm1.put("Geek3", 3); Map<String, Integer> hm2 = new HashMap<>(); hm2.put("Geek3", 3); hm2.put("Geek2", 2); hm2.put("Geek1", 1); Map<String, Integer> hm3 = new HashMap<>(); hm3.put("Geek1", 1); hm3.put("Geek2", 2); hm3.put("Geek4", 4); System.out.println("First HashMap: " + hm1); System.out.println("Second HashMap: " + hm2); System.out.println("Third HashMap: " + hm3); // Checking equality between the maps System.out.println("Is hm1 equal to hm2? " + hm1.equals(hm2)); System.out.println("Is hm1 equal to hm3? " + hm1.equals(hm3)); } } OutputFirst HashMap: {Geek3=3, Geek2=2, Geek1=1} Second HashMap: {Geek3=3, Geek2=2, Geek1=1} Third HashMap: {Geek4=4, Geek2=2, Geek1=1} Is hm1 equal to hm2? true Is hm1 equal to hm3? false Comment C chinmoy lenka Follow 0 Improve C chinmoy lenka Follow 0 Improve Article Tags : Misc Java Java-Collections Java - util package Java-HashMap Java-AbstractMap +2 More Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings8 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java9 min readAccess Modifiers in Java4 min readJava Constructors4 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages7 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java4 min readJava Comparator Interface4 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java10 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management4 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read Like