For example, I get error "Cannot convert from long to int" while trying following
long size = 32;
int a[] = new int[size];
Java restrict array size to int
, which limits me to create max ~2 billion elements.
Why do we have this limit?
For example, I get error "Cannot convert from long to int" while trying following
long size = 32;
int a[] = new int[size];
Java restrict array size to int
, which limits me to create max ~2 billion elements.
Why do we have this limit?
Every array has a length
, and it's specified in the JLS-10.7 that it is an int
.
The public final field length, which contains the number of components of the array. length may be positive or zero.
public final int length = X ;