Java examples for Collection Framework:ArrayList
To remove all elements from the ArrayList use void clear() method.
import java.util.ArrayList; public class Main { public static void main(String[] args) { ArrayList arrayList = new ArrayList(); arrayList.add("1"); arrayList.add("2"); arrayList.add("3"); System.out.println("Size of ArrayList before removing elements : " + arrayList.size()); arrayList.clear();//from w w w. j a va 2 s .c o m System.out.println("Size of ArrayList after removing elements : " + arrayList.size()); } }