I have an Array with Defualt “Cat”, “Dog, “Simon”, “Smith”
the length is therefore 3.
If I want to edit smith I type array[3] = “JR Smith”
but if user want to add another thing to the array I tried: array[4] = “Car”
But it gave me out of bounds.
How do I extend an array outside it’s initialization?
//Simon
EDIT*
Ye I know there is List. But isnt there a way with array. becuase it took me ages to write like 200 length array…
You can not extend an array outside its initialization. For such a purpose use of an ArrayList is advised. It has the property to grow beyond its predefined size.
A simple example of using ArrayList can be found here