Question: what is the difference between arraylist clear() and removeall() methods?
Answer: The clear() method removes all the elements of a single ArrayList . It's a fast operation, as it just sets the array elements to null . The removeAll(Collection) method, which is inherited from AbstractCollection , removes all the elements that are in the argument collection from the collection you call the method on.