This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Since n must be an int (JLS 15.10 Array Creation Expressions), the maximal (theoretical) length of an array is Integer.MAX_VALUE, i.e. 2147483647. I say theoretical because when I run the following program, I get an OutOfMemoryError which means that there was not enough memory to run the program.
The number is a little less than one fourth of the number of bytes available on the stack (64 MB) - which makes sense, as each int takes four bytes. Try varying the memory allocated to the stack by running with -Xmx: java -Xmx128m MyClass This allocates up to 128MB to the stack (assuming your system has it available, of course).