ArrayList
TheArrayList class is a resizable array, which can be found in the java.util package.The difference between a built-in array and an ArrayList is that the size of an array cannot be modified (if you want to add or remove elements to/from an array, you have to create a new one). While elements can be added and removed from an ArrayList whenever you want.
import java.util.ArrayList;public class Main {
public static void main(String[] args) {
ArrayList cars = new ArrayList();
cars.add("Volvo");
cars.add("BMW");
cars.add("Ford");
cars.add("Mazda");
System.out.println(cars);
}
}