Why does this not compile?
Map<Integer, List<String>> myMap;
myMap = new HashMap<Integer, ArrayList<String>>();
With the error:
Type mismatch: cannot convert from HashMap<Integer,ArrayList<String>> to
Map<Integer,List<String>>
Why can't I use a generic as a generic?
It's not like I'm asking the difference between List<Dog>
and List<Animal>
. Contract between List<String>
and ArrayList<String>
should match.