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

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -