HashMap - how will it store objects where hashcode is same? How will it retrieve them?
Réponses aux questions d'entretien
Utilisateur anonyme
18 juil. 2011
Basically if there is a hashcode collision then HashMap would rely on equals method for further equality checks.
Utilisateur anonyme
20 août 2011
In case of key hashcode collision, the bucket will be same but considering each bucket location of hashmap as a linked list, the key-value pair will be stored on the next node in the same bucket. At the time of retreival, it will use keys.equal to get the correct node.