What is the difference between ArrayList.clear() and ArrayList.removeAll()?
The source code for clear(): public void clear() { modCount++; // Let gc do its work for (int i = 0; i < size; i++) elementData[i] = null; size = 0; } The source code for removeAll()(As defined in AbstractCollection): public boolean removeAll(Collection<?> c) { boolean modified = false; Iterator<?> e = iterator(); while (e.hasNext()) … Read more