November 2017
Intermediate to advanced
398 pages
10h 14m
English
As everything with the JVM memory regions, there is a limit on the number of array size that the program can allocate. This limit is platform specific. If your application uses an array size more than the allowed size for the underlying platform, you will see this error. The following code will help you understand this error:
public class ArraySizeExceedsLimit { public static void main(String[] args){ ArraySizeExceedsLimit arr = new ArraySizeExceedsLimit(); arr.arraySizeChecker(); } public void arraySizeChecker(){ int[] myIntArray = new int[Integer.MAX_VALUE-1]; }}
If you run the preceding program, it is going to throw the desired error as the int primitives that we are trying ...
Read now
Unlock full access