Guest_imported
New member
- Jan 1, 1970
- 0
Hi everyone!
I've got a question for you. Is there the same mechanism in Java for creating dynamic arrays as there is in Visual Basic?
I don't know in advance how many elements there going to be in array, and I need to resize array dynamically along with adding new elements to it.
Something like in this piece:
int[] arr;
int count;
int arrelem=0;
for (count=0;count<5;count++)
arr[count]=arrelem;
arrelem++;
Java doesn't seem to let to use this approach. It insists on initializing array with specifying the expected number of elements. So, is this a dead end, or there is some workaround?
Thank you in advance.
I've got a question for you. Is there the same mechanism in Java for creating dynamic arrays as there is in Visual Basic?
I don't know in advance how many elements there going to be in array, and I need to resize array dynamically along with adding new elements to it.
Something like in this piece:
int[] arr;
int count;
int arrelem=0;
for (count=0;count<5;count++)
arr[count]=arrelem;
arrelem++;
Java doesn't seem to let to use this approach. It insists on initializing array with specifying the expected number of elements. So, is this a dead end, or there is some workaround?
Thank you in advance.