The clear() method of Java AbstractCollection in Java is used to remove all of the elements from the Collection. Using the clear() method only clears all the element from the collection and does not delete the collection. In other words, it can be said that the clear() method is used to only empty an existing AbstractCollection.
Return Value: The function does not return any value.
Below programs illustrate the AbstractCollection.clear() method:
AbstractCollection: [Welcome, To, Geeks, 4, Geeks] AbstractCollection after using clear: 
AbstractCollection: [15, 20, 25, 30, 35] AbstractCollection after using clear: 
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.