Is there a limit to the number of elements a Java array can contain? If so, what is it?
Going by this article http://en.wikipedia.org/wiki/Criticism_of_Java#Large_arrays:
Java has been criticized for not supporting arrays of more than 231−1 (about 2.1 billion) elements. This is a limitation of the language; the Java Language Specification, Section 10.4, states that:
Arrays must be indexed by int values... An attempt to access an array component with a long index value results in a compile-time error.
Supporting large arrays would also require changes to the JVM. This limitation manifests itself in areas such as collections being limited to 2 billion elements and the inability to memory map files larger than 2 GiB. Java also lacks true multidimensional arrays (contiguously allocated single blocks of memory accessed by a single indirection), which limits performance for scientific and technical computing.