Given an ArrayList, and we have to remove/clear all elements using Java program.
ArrayList.clear()
This method is used to clear/remove all elements from an ArrayList.
In this program, we have 5 elements which have been added in the ArrayList, the elements are 100, 200, 300, 400 and 500. So, total numbers of elements are 5 and after removing all the elements ArrayList, total number of elements will be 0.
Consider the program
Output