Difference between HashMap and Map in Java..? [duplicate]

Solution 1:

Map is an interface, i.e. an abstract "thing" that defines how something can be used. HashMap is an implementation of that interface.

Solution 2:

Map<K,V> is an interface, HashMap<K,V> is a class that implements Map.

you can do

Map<Key,Value> map = new HashMap<Key,Value>();

Here you have a link to the documentation of each one: Map, HashMap.