From the APIs, we can see, the objects which stored in the Hashtable should implement hashCode() and equals() methods.
To successfully store and retrieve objects from a hashtable, the objects used as keys must implement the hashCode method and the equals method.
But, However the HashMap implementation does allow null keys. In the java.util.HashMap implementation, in case the key is null, it uses a surrogate object to act as the key. The surrogate key is a dummy non-null java object. However using a null key in HashMap overwrites the previous null-key : value mapping.
I think, it should be the reason.
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|