You're right in that "List<String>
is a subtype of Collection<String>
". And if A
extends B
, List<A>
is not a subtype of List<B>
.
Taking that one step further, a HashMap<String, List<String>>
is not a HashMap<String, Collection<String>>
.
The same reasoning applies, where A
is List
and B
is Collection
. If a HashMap<String, List<String>>
was a HashMap<String, Collection<String>>
, then you could put
a Vector<String>
into a HashMap<String, List<String>>
by assigning it to a HashMap<String, Collection<String>>
, even though a Vector
isn't a List
, and so it's not allowed.