*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes arrays in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "arrays in java" Watch "arrays in java" New topic
Author

arrays in java

Prasanna Govindan
Greenhorn

Joined: Aug 21, 2005
Posts: 2
hi java Gurus,
Please some help....

i want to create an array whose size is determined at runtime
i dont want to give the dimensions of the array at declaration.
for eg:
int [] ary;
int index=0;
ary[index]=12
gives Null pointer exception.

Is there any way to declare an array and not mention the size of it and insert values into it...faciliating the size to be determined at runtime.

Thanks
Prasanna
Thomas Drew
Ranch Hand

Joined: Sep 15, 2004
Posts: 47
Array are not to be dynamic. You should use an ArrayList or Vectors.
Victor Flores O'connor
Greenhorn

Joined: Aug 05, 2005
Posts: 2
you mean like this???
'size' can be whatever you want at runtime

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: arrays in java
 
Similar Threads
recursion find number of times int appears in array...
Values of Hash Map to be 2-dimensional array
byte and short
LIS Question
Hangman BufferReader ??