Online Java Compiler By
JavaTpoint.com
import java.util.IdentityHashMap; public class IdentityHashMapEqualsExample1 { public static void main(String[] args) { //Creating an object of IdentityHashMap class IdentityHashMap
map1 = new IdentityHashMap
(4); //Putting key-value pairs inside map1 map1.put("Java", 1); map1.put("is", 2); map1.put("programming", 3); map1.put("language", 4); //Creating another object of the Java IdentityHashMap IdentityHashMap
map2 = new IdentityHashMap
(4); //Putting key-value pairs inside map2 map2.put("Java", 1); map2.put("is", 2); map2.put("programming", 3); map2.put("language", 4); //Creating another object of the Java IdentityHashMap IdentityHashMap
map3 = new IdentityHashMap
(4); //Putting key-value pairs inside map3 map3.put("Java", 0); map3.put("is", 1); map3.put("programming", 2); map3.put("language", 3); //Checking if map1 and map2 are equal System.out.println(map1.equals(map2)); //Checking if map1 and map3 are equal System.out.println(map1.equals(map3)); //Checking if map2 and map3 are equal System.out.println(map2.equals(map3)); } }
Output