View Single Post
  #2 (permalink)  
Old 08-07-2007, 07:53 AM
carl carl is offline
Member
 
Join Date: Jul 2007
Posts: 35
carl is on a distinguished road
Make a new, larger array and copy the values of the old one into the new one.

Code:
Object[] tempArray = new Object[myArray.length + increment]; for (int i = 0; i < myArray.length; i++) tempArray[i] = myArray[i]; myArray = tempArray;
Every time you add an element, you should check to see if the array is at its limit, and if it is, call a method that makes it larger.

I do suggest learning the linked list method, however, as they offer much more functionality (such as the logical extension of them, binary search trees).
Reply With Quote