Capgemini Interview Question

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

Interview Answer

Anonymous

May 28, 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.