Why don’t Java Generics support primitive types?
Generics in Java are an entirely compile-time construct – the compiler turns all generic uses into casts to the right type. This is to maintain backwards compatibility with previous JVM runtimes. This: List<ClassA> list = new ArrayList<ClassA>(); list.add(new ClassA()); ClassA a = list.get(0); gets turned into (roughly): List list = new ArrayList(); list.add(new ClassA()); ClassA … Read more