Hi , can anyone tell me..that is there any limit of adding elements in array..like as if i cannont add more that X elements in an array?
also what is the data type of the length field of the array...? i didnt got anything relating to this anywhere..
Thanx in advance
Regards<br />Sandy<br />[SCJP 5.0 - 75%]<br />[SCWCD 1.4 - 85%]<br />------------------<br />Tiger, Tiger burning bright,<br />Like a geek who works all night,<br />What new-fangled bit or byte,<br />Could ease the hacker's weary plight?
and mentioning that my virtual memory is set to 1536-3072 if the program give same output on your machine that note that u can have it as 15475348 which i think will not be true,otherwise u can have this as VM dependent.
Yes, I think it is int too. As far as I can see, the Java Language Specification mentions only a public final member length with no type specified. But in an example showing an equivalent class definition of an array, the length field is of type int. So that would mean a maximum length of an array is 2147483647 elements.
As an example, an array can be created as in the following:
The resultant initialized array of 42 zero (the default value) elements is fixed in length. You cannot add a 43rd element to it.
Of course there is a limit to the amount of memory available to the Java Virtual Machine, so for very large arrays you will probably get an OutOfMemoryError before the theoretical limit is reached.