Java tutorial
import java.util.ArrayList; public class Main { public static void main(String[] args) { ArrayList<Integer> ids = new ArrayList<>(); int total = ids.size(); // total will be zero System.out.println("ArrayList size is " + total); System.out.println("ArrayList elements are " + ids); ids.add(new Integer(10)); // Adding an Integer object. ids.add(20); // Autoboxing ids.add(30); // Autoboxing total = ids.size(); // total will be 3 System.out.println("ArrayList size is " + total); System.out.println("ArrayList elements are " + ids); ids.clear(); total = ids.size(); // total will be 0 System.out.println("ArrayList size is " + total); System.out.println("ArrayList elements are " + ids); } }