Untitled Document

Subscribe here to get updates on new Videos


16. ArrayList details?




previous homenext

The underlined data structure Resizable Array or Growable Array.
Duplicates are allowed.
Insertion order is preserved.
Heterogeneous objects are allowed ( Except TreeSet & TreeMap everywhere heterogeneous objects are allowed ).
Null Insertion is possible.

ArrayList Constructors:

1. ArralyList al= new ArrayList()
Creates an empty Array list object with default initial capacity 10.
Once Array List reaches its map capacity a new Array List will be created with new capacity=(currentcapacity*3/2)+1

ArrayList Constructors:

2. ArrayList al=new ArrayList(int initialCapacity);
3. ArrayList al=new ArrayList(Collection c);

Usually we can use collections to hold and transfer Objects from one place to another place, to provide support for this requirement every Collection already implements Serializable and Cloneable interfaces. ArrayList and Vector classes implements RandomAccess interface so that we can access any Random element with the same speed. Hence if our frequent operation is retrieval operation then ArrayList is the best choice.


1. ArrayList is best choice if our frequent operation is retrieval operation (Because ArrayList implements RandomAccess Interfaces)
2. ArrayList is the worst Choice if our frequent operation is insertion or deletion in the middle (Because several shift operation are require)