Here is an example of the code that has been confusing me.
If I try to create a collection of a bounded type and assign the same variable to another variable that is another collection of unbounded unknown type, the code works.
List<? extends Number> numberList = new ArrayList<>();
List<?> anotherList = numberList; // OK
If I try to do the same inside a Map I get the "incompatible types" error.
Map<String, List<? extends Number>> numberMap = new HashMap<>();
Map<String, List<?>> anotherMap = numberMap; // ERROR
The error says:
Map<String,List<? extends Number>> cannot be converted to Map<String,List<?>>
Isn't Map<String,List<? extends Number>>
a type of Map<String,List<?>>
?
Here's the whole class for your convenience https://ideone.com/AZgV9H
I'm trying to understand why this isn't working and how should I change it in order to make it work.