Question d’entretien chez Capgemini

When would you want to use a Map vs a HashMap in Java?

Réponse à la question d'entretien

Utilisateur anonyme

28 mai 2020

HashMap is a more specific data type and therefore less general interface, if you were wanting a more general interface you would use Map. However inside the implementation HashMap and Map are equivalents, and Map will compile down to HashMap if a more specific data type is not specified.