Java / List and its implementations
Java Collection: Difference between ArrayList.clear() and ArrayList.removeAll().
ArrayList.clear() will traverse the underlying Array and set each entry to null that eventually removes all the elements of ArrayLIst.
removeAll(collection) traverse through the ArrayList comparing for collection and remove the element, if it exists.
ArrayList.clear() is comparatively faster as it does not perform any comparison.
More Related questions...