Java Quiz 50- Which classes should be preferred to be used as key in the HashMap #java #quiz

preview_player
Показать описание
Java Quiz 50: Which classes should be preferred to be used as keys in a HashMap?
When choosing a class to use as a key in a HashMap, it's crucial to ensure the class properly implements the hashCode() and equals() methods. Immutable classes like String, Integer, and Long are typically preferred. Do you know why? Take this quiz to test your understanding of Java collections!

#java #quiz #javaquiz #codingtips #javamcq
Рекомендации по теме
Комментарии
Автор

It is advised that an object that is to be used as a key to a map should be immutable or else the behaviour of the map would be unpredictable if key is altered accidentally by an operation.

turtle