Java: Maximum length of array

The maximum length of an array in Java is 2,147,483,647 (the maximum size of an int, 231-1).

This limit is not explicitly stated in the JLS but implied by the fact that in an array creation, the length expression must be of type int.

15.10 Array Creation Expression


Each dimension expression undergoes unary numeric promotion (§5.6.1). The promoted type must be int, or a compile-time error occurs. JLS §15.10 Array Creation Expression


Be the first to comment!