Reasons to allow null as a HashMap key?

Why did Java decide to allow "null" as a key in HashMap? Since we know that hashcode () cannot be calculated by a zero value. Is there any design consideration for this solution to allow a null key in a HashMap that is not in the Hashtable (other than accounting as the default)?

+5
source share
1 answer

From JDK 1.2 Summary of the Java Collections API (I don’t know where to find the official version on the Oracle website):

​​ HashMap. TreeMap , ​​ ArrayMap, , . , .

, -.

+6

All Articles