HashMap allows duplicates?

Viewed 114478

I have a doubt regarding HashMap, as we all know HashMap allows one null key and value pair, My question here is

If I wrote like this,

m.put(null,null);
m.put(null,a);

Will it throw a (error or exception) or will it override the value or what will be the value of returing??

6 Answers
m.put(null,null); // here key=null, value=null
m.put(null,a);    // here also key=null, and value=a

Duplicate keys are not allowed in hashmap.
However,value can be duplicated.

Related