Next: Dealing with the dimension
Up: Unit 12
Previous: Summary
We have seen that we can use arrays whenever we have to store and
manipulate collections of elements. However, the use of arrays for this
purpose presents several limitations related to the way arrays are handled in
Java:
- the dimension of an array is determined the moment the array is created,
and cannot be changed later on;
- the array occupies an amount of memory that is proportional to its size,
independently of the number of elements that are actually of interest;
- if we want to keep the elements of the collection ordered, and insert a
new value in its correct position, or remove it, then, for each such
operation we may need to move many elements (on the average, half of the
elements of the array); this is very inefficient.
Next: Dealing with the dimension
Up: Unit 12
Previous: Summary