Dynamic allocation of a primitive type variable in Java

758 views Asked by At

Can I dynamically allocate a primitive type variable, say int? I can't see how this could be done other than to wrap it into an object Integer or into a single-element array int[1].

I tried:

int i = new int(5);

Is it forbidden? If so, why?

EDIT

Possible (theoretical) application - creating a collection-like data structure for storing primitive types.

0

There are 0 answers