diff --git a/java-collections-maps-3/src/main/java/com/baeldung/map/identity/IdentityHashMapDemonstrator.java b/java-collections-maps-3/src/main/java/com/baeldung/map/identity/IdentityHashMapDemonstrator.java index 155cdc06e7..dbd309eab3 100644 --- a/java-collections-maps-3/src/main/java/com/baeldung/map/identity/IdentityHashMapDemonstrator.java +++ b/java-collections-maps-3/src/main/java/com/baeldung/map/identity/IdentityHashMapDemonstrator.java @@ -11,7 +11,7 @@ public class IdentityHashMapDemonstrator { updateWithNewValue(copiedMap); iterateIdentityHashMap(copiedMap); addNullKeyValue(); - demoHashMapVsIdentityMap(identityHashMap); + demoHashMapVsIdentityMap(); demoMutableKeys(); Map synchronizedMap = getSynchronizedMap(); @@ -106,7 +106,13 @@ public class IdentityHashMapDemonstrator { System.out.println("IdentityHashMap: " + identityHashMap); } - private static void demoHashMapVsIdentityMap(IdentityHashMap identityHashMap) { + private static void demoHashMapVsIdentityMap() { + IdentityHashMap identityHashMap = new IdentityHashMap<>(); + identityHashMap.put("title", "Harry Potter and the Goblet of Fire"); + identityHashMap.put("author", "J. K. Rowling"); + identityHashMap.put("language", "English"); + identityHashMap.put("genre", "Fantasy"); + HashMap hashMap = new HashMap<>(identityHashMap); hashMap.put(new String("genre"), "Drama"); assert (4 == hashMap.size());