You can check it by using Integer.MAX_VALUE - 5.
public class Foo {
public static void main(String[] args) {
Object[] arr = new Object[Integer.MAX_VALUE - 4];
}
}
It will throw an exception saying:
Exception in thread "main" java.lang.OutOfMemoryError:
Requested array size exceeds VM limit
Hope this answer helps you!