I am aware that we can have 1 null key in a hashmap.
If I try to put second null key in the hashmap, previous one is overridden.
Hashmap performs all the operation by evaluating the keys for methods hashcode and equals to check the existance of key.
My question here is: Is it possible to take hashcode of null value ?
If yes, how ?
If no, how does duplicate null key is avoided in the hashmap ??
Sample code :
Map<String, Integer> map = new HashMap<String, Integer>();
// put null key
map.put(null , 6);
// put duplicate key
map.put(null , 9);