Do Java arrays have a maximum size? -
Is there a limit to the number of elements in the Java array? If yes, what is it?
The correct answer is not seen, even if it is very easy test.
In the recent hotspot VM, the correct answer is integer. MAX_VALUE - 5
. Once you go to it:
public square fu {public static zero main (string [] args) {object [] array = new object [integer.mx_avn-4]; }}
You get:
Exception in thread "main" java.lang.OutOfMemoryError: The requested array size exceeds the VM limit
Comments
Post a Comment