Assuming that arraylist is defined as ArrayList arraylist, is arraylist.removeAll(arraylist) equivalent to arraylist.clear()?
arraylist
ArrayList arraylist
The time complexity of ArrayList.clear() is O(n) and of removeAll is O(n^2).
ArrayList.clear()
O(n)
removeAll
O(n^2)
So yes, ArrayList.clear is much faster.
ArrayList.clear