This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
What is the maximum size of a array in javaapplet? I want to define a very big array,for example: int data in my applet, then read data from ASCII file into this array, then draw three lines accoring to this array, is it possible? I tested a smaller array first: int data, then tried to draw a three lines in canvas according to this data array. I checked data array, I have got all the data inside the data, but when I drew, I only got one line, then I got the error message: arrayindexoutofboundexception:72000 and a lot of other error? What to do with these? Thanks for your help!!
In theory I suppose array size is only limited by the maximum size you can define the array to be, in which case that is the max size an integer can be in Java. Since you get a 32-bit two's compliment number to use then this is 2147483647 - way bigger than 1728000. I would suspect though that creating such a big array would have significant performance issues, especially in an applet. I'd have a look at the BufferedReaders available in java.io for your requirements. That aside, your problem is not to do with running out of space in an array. An ArrayIndexOutOfBoundException occurs when you try to reference an array element which is beyond the bounds of the defined array. e.g.
Remember that arrays are indexed from 0 not 1. So the maximum index in your 2D array is data, and you seem to be asking for the 72000 element.