what's the difference between array and arraylist

  • Thread starter Thread starter Hei
  • Start date Start date
Hi,

There are several differences, but the biggest, in my opinion, is that an
arraylist grows as you add items to it and does not have to be redimmed the
allow additional elements. Arraylists are sortable, searchable, etc - they
are far superior to arrays.

HTH,

Bernie Yaeger
 
Hi Hei,

In additon to Bernie,

When you have a fixed array, there is in use no difference.
(And the old array is than very simple to make).

When you have to do something else with the array than read from it, use
everything else than the old array by example the arraylist.

I hope that this helps a little bit?

Cor
 
* "Hei" <[email protected]> scripsit:
[...]

Arrays cannot be changed in size at runtime (except using 'ReDim' which
will create a new array, copy the old array in the new array and destroy
the old array). The arraylist is more dynamic, you can add and remove
items without loosing performance.
 
Herfried K. Wagner said:
* "Hei" <[email protected]> scripsit:
[...]

Arrays cannot be changed in size at runtime (except using 'ReDim'
which will create a new array, copy the old array in the new array
and destroy the old array).

.... if 'ReDim' is followed by a 'Preserve'
 
* "Armin Zingler said:
... if 'ReDim' is followed by a 'Preserve'

Thanks, that's needed in order to get the same behavior as with the
arraylist.

;-)
 
Herfried K. Wagner said:
Thanks, that's needed in order to get the same behavior as with
the arraylist.

;-)

That's also needed when you want the behavior you described with the array.
 
Back
Top