Why does the declaration List<int> fail to compile in Java?
Correct answer C. Type arguments must be reference types
Explanation
A generic type argument must be a reference type, so a primitive such as int is not allowed. Generics are implemented by erasure, which treats type parameters as Object or their bound, and a primitive is not an Object. The usual solution is List, with autoboxing converting between int and Integer automatically.
Answer checked How we write and check questions
Discussion