How to use remove(obj), remove(index), and removeAll() methods in Java list collections?


remove(int index) − Removes the element at position index from the invoking list and returns the deleted element. The resulting list is compacted. That is, the indexes of subsequent elements are decremented by one.

removeRange(int fromIndex, int toIndex) − Removes all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive.

removeAll(Collection<?> c) − Removes from this list all of its elements that are contained in the specified collection (optional operation).

Updated on: 30-Jul-2019

131 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements