Paul Clapham wrote:Yes, that's correct. (Although you might not have enough memory to create an array with Integer.MAX_VALUE elements.)
Even though I am unable to see why someone would want a "huge" array, I still wonder why did they put this limit ?
A larger index would be wasteful and there would be very little benefit to doing it. A 4-byte int has been the most common word size on computer hardware for many years now, and will continue to be until 64-bit machines become more popular in the next few years.
The smallest possible thing you cold store in an array is a byte - which takes up (rather obviously) at least one byte to store. Using a long for the array index type would mean you'd have at least 2^31 bytes - so that's 2 GB just for that one array. But around the time the JLS (Java Language Specification) was written it was more typical for a desktop computer to have something like 4 MB of RAM (not that Java was originally written to run on desktop computers, mind you). So there was no point in enabling something that you could not possibly make use of.