AbstractCollection clear() Method in Java with Examples
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: 
My Personal Notes arrow_drop_up
Please Login to comment...