Reverse ArrayList
The
Collections interface also provides methods for bulk operations that work on the entire collection:
containsAll - returns the boolean value
true if this collection contains all the elements in the called collection, otherwise it returns
false.
addAll - adds all of the specified elements to the specified collection. The elements to be added can be specified individually or as an array.
removeAll - is used to remove all elements from the list that are contained in the specified collection.
clear - remove all elements
reverse - array reverse
etc.
Example
Using
removeAll.
ArrayList<Integer> first = new ArrayList<Integer>();
first.add(1);
first.add(2);
first.add(3);
ArrayList<Integer> second = new ArrayList<Integer>();
second.add(1);
second.add(2);
// removes all elements from the second list,
// if they exist in the first list
second.removeAll(first);