I want to implement a map wrapper that use genericity to enforce a type relation between the key and the value. The following code does not compile :
Map<Class<? extends Serializable>, List<List<? extends Serializable>>> collection = new HashMap();
private <T extends Serializable> void add(Class<T> type, List<List<T>> item) {
collection.put(type, item);
}
whereas this compile :
Map<Class<? extends Serializable>, List<? extends Serializable>> collection = new HashMap();
private <T extends Serializable> void add(Class<T> type, List<T> item) {
collection.put(type, item);
}
why is there a difference between a 2nd and a 3rd level generic type ?