Click to See Complete Forum and Search --> : redemensioning arrays


Rippin
May 9th, 2000, 11:10 AM
I am a new to Java. I have, to this point, been using VB for all of my developmental needs. In VB, once you have an array declared, say with 15 items, you can "redimension" it and make it bigger or smaller. I have read some books and looked online but have not found how to do this in Java. I fully understand how to declare an array and use it, just need to know how to "re-size" it. Any help is appreciated.

Thanks,
Rippin

weaver
May 9th, 2000, 08:08 PM
If you're not worried about the data in the array, you can just use the following:

myArray = new int[somenumber];

However, if you need to maintain the data that is in the array, I suggest you use an instance of the Vector class. It is basically an array which can be resized, but it takes care of this on its own.

-------------------------------------------
weaver
icq# 64665116
Please rate this post.
http://weaver.x7.htmlplanet.com