Java / Map and its implementations
How null key is handled in HashMap?
The null key is handled specially in HashMap using 2 separate methods putForNullKey(V value) and getForNullKey(). Null key is mapped always to 0th Index. This null key scenario is treated in isolated methods to eliminate null key code check and improve performance of get and put methods. The equals() and hashcode() method are not used in case of null key in HashMap.
More Related questions...