changed code to show copy-paste ready code comment

This commit is contained in:
Seshu Thanneeru 2022-01-19 19:44:51 +05:30
parent 6190f6801f
commit 017badd303
1 changed files with 8 additions and 2 deletions

View File

@ -11,7 +11,7 @@ public class IdentityHashMapDemonstrator {
updateWithNewValue(copiedMap);
iterateIdentityHashMap(copiedMap);
addNullKeyValue();
demoHashMapVsIdentityMap(identityHashMap);
demoHashMapVsIdentityMap();
demoMutableKeys();
Map<String, String> synchronizedMap = getSynchronizedMap();
@ -106,7 +106,13 @@ public class IdentityHashMapDemonstrator {
System.out.println("IdentityHashMap: " + identityHashMap);
}
private static void demoHashMapVsIdentityMap(IdentityHashMap<String, String> identityHashMap) {
private static void demoHashMapVsIdentityMap() {
IdentityHashMap<String, String> 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<String, String> hashMap = new HashMap<>(identityHashMap);
hashMap.put(new String("genre"), "Drama");
assert (4 == hashMap.size());