I know that List
and Map
are interfaces that can be implemented and ArrayList
and HashMap
are classes whose objects can be created and used.
I know the difference between the two pairs. My actual question is, is there a difference between the following two statements?
HashMap< K, V> myMap = new HashMap<K, V>();
Map< K, V> myMap = new HashMap<K, V>();
And if there is, then what is the difference and when should I use which one? Similarly, what is the difference between:
ArrayList< Integer> myList = new ArrayList<Integer>();
List< Integer> myList = new ArrayList<Integer>();