4
Apa perbedaan antara <? extends Base> dan <T extends Base>?
Dalam contoh ini: import java.util.*; public class Example { static void doesntCompile(Map<Integer, List<? extends Number>> map) {} static <T extends Number> void compiles(Map<Integer, List<T>> map) {} static void function(List<? extends Number> outer) { doesntCompile(new HashMap<Integer, List<Integer>>()); compiles(new HashMap<Integer, List<Integer>>()); } } doesntCompile() gagal dikompilasi dengan: Example.java:9: error: incompatible types: HashMap<Integer,List<Integer>> …