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

Java 8Object Oriented ProgrammingProgramming

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).

Published on 17-Jan-2018 11:00:50