Map<String, String> map = new HashMap<String, String>();
I am aware about the internal working of map. if the hashcode for two keys are same collision occurs and it will store in linkedlist. but what if put that key again.
is there any check on that ? or it will simply replace the value without checking ?
to elaborate more
map.put("sparsh", "sparsh");
map.put("sparsh", "1");
it will replace value "sparsh" to "1"
map.put("sparsh", "1");
map.put("sparsh", "1");
what will happen in above case, any replacement ?
and some different context from above question
System.out.println(map.put("sparsh", "sparsh"));
System.out.println(map.put("sparsh", "1"));
it is giving me first "null" and then "sparsh"(key). what is the reason behind that, if anyone has clarity about that.