• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

maximum array size in applet

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is the maximum size of a array in java applet?
I want to define a very big array,for example: int data[1728000][3] 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[72000][3], 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!!
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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[71999][2], and you seem to be asking for the 72000 element.
 
reply
    Bookmark Topic Watch Topic
  • New Topic