PrimitiveTypeParameter
DRAFT

Misconception:

A generic type like ArrayList<T> can be instantiated by assigning any type, including a primitive type, to the type parameter T. So one can define an array list of ints with ArrayList<int>.

Incorrect

Type parameters of generic types can be assigned primitive types

Correct

Correction
Here is what's right.

One can only use reference types. Primitive types can’t be used as type arguments.

So, ArrayList<Integer> is ok, but ArrayList<int> is wrong.

Language

Java

Concepts

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.