Adding a single element to the list by calling the add() method:
public boolean add(Object element) public boolean add(int index, Object element)
import java.util.ArrayList; import java.util.List; public class MainClass { public static void main(String args[]) throws Exception { // Create/fill collection List list = new ArrayList(); list.add("A"); list.add("B"); list.add("C"); System.out.println(list); } }
[A, B, C]