HashMap
-
What will happen if you store null key in HashMap?
In HashMap, only one null key is allowed. If key of the HashMap is null then it will always be present in the index 0. NullPointerException is thrown if you…
-
Can we use any class as a Map key in HashMap?
Yes. We can use any class as a Map key, however the following points should be considered before using them. If a class overrides an equals() method, it should also…
-
What is the importance of hashcode() and equals() methods?
HashMap uses the key object hashCode() and equals methods to determine the index to put the key-value pair. The methods are also used when we try to get the value…




