top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the max size of an array allowed in java?

+1 vote
385 views
What is the max size of an array allowed in java?
posted Aug 4, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

In Java, arrays internally use integers (int not Integer) for index, the max size is limited by the max size of integers. So theoretically it is 2^31-1 = **********, which is Integer.MAX_VALUE.

But in recent HotSpot JVM it has been observed that the max size of array can be Integer.MAX_VALUE - 5.

answer Aug 4, 2015 by Ashwini Borkar
...