ArrayList is a resizable-array implementation of the List interface. ArrayList offers an alternative to traditional arrays which are fixed in size and cannot grow beyond the capacity specified during initialization.
The ArrayList class also offers a lot of useful methods which we can use in our programs. It implements all optional list operations, and permits all elements, including null.
Java provides the ArrayList class as part of the Java Collections Framework. For an overview of the Java Collections Framework, check out my post Overview of the Java Collections Framework.
The following example illustrates the ArrayList class.
Example
Output
The above program showed the use of some of the common methods of the ArrayList class. For a complete list of all the available methods, refer the official docs.
Now since you know how to use the ArrayList class, check out another implementation of the List interface, the LinkedList class in Java.