This post highlight's some of the important points about ArrayList.
- ArrayList class extends AbstractList and implements List interface
- Data structure used for ArrayList is resizable or growable arrays
- Duplicates are allowed in ArrayList
- Insertion order is preserved
- Heterogeneous objects can be inserted.
- Null values are allowed
- ArrayList is serializable
- ArrayList is clonable
Now Lets try to perform some basic operation and learn more about ArrayList.
Exercise 1: Create a ArrayList object
Array List has 3 constructors.
Exercise 2: Add 3 integers to ArrayList and check the size of the
Note: ArrayList her uses Generics, which is specifying what type of a object we are inserting in.
Exercise 3: Print the contents of a array using iterator