The capacity of an
Array
is fixed.
Where as,
ArrayList
can increase and decrease size dynamically.
An
Array
is a collection of similar items.
Where as,
ArrayList
can hold item of different types.
Array is in the System namespace.
Where as, ArrayList is in the System.Collections namespace.
An
Array
can have multiple dimensions.
Where as,
ArrayList
always has exactly one dimension.
We can set the lower bound of an
Array
.
Where as, the lower bound of an
ArrayList
is always zero.
Array
is faster and that is because
ArrayList
uses a fixed amount of array.
However when you add an element to the
ArrayList
and it overflows. It creates a new
Array
and copies every element from the old one to the new one.
You will only feel this if you add to often.
Since the add from
ArrayList
is O(n) and the add to the
Array
is O(1).
However because
ArrayList
uses an
Array
is faster to search O(1) in it than normal lists O(n).
List over arrays.
If you do not exceed the capacity it is going to be as fast as an array.
Better handling and much easier way of doing things.
Please refer:
ArrayList and List Collection Types[
^]