1 Answers
Can we use null as a key for a map collection? - Java Interview Question
Yes, in Java, it is possible to use null as a key for a map collection such as HashMap or HashTable. However, it is important to note that HashMap allows one null key while HashTable does not allow null keys.
Using null as a key can be useful in certain scenarios but should be done with caution to avoid NullPointerExceptions.
Overall, it is recommended to check the documentation of the specific map implementation being used to understand how null keys are handled.
Please login or Register to submit your answer