In this example we will show the method to create an ArrayList in Java.
Source Code
package com.beginner.examples;
import java.util.ArrayList;
public class CreateArrayList {
public static void main(String[] args) {
ArrayList arrays = new ArrayList(); // create an ArrayList
arrays.add("a");
arrays.add("b");
System.out.println(arrays);
}
}
Output:
[a, b]
References
Imported packages in Java documentation: