Java's collections offer three "bulk" operations; write them yourself. In ListSetOps, write a generic class MyArrayList<E> on a growing array (add, get, contains, size, toString, and a copy constructor) with
public boolean addAll(MyArrayList<E> other) // adds every element of other
public boolean removeAll(MyArrayList<E> other) // removes the elements that are also in other
public boolean retainAll(MyArrayList<E> other) // keeps only the elements that are also in other
Each returns true if the list changed. removeAll and retainAll must work in one pass, without a second array: move the elements to keep towards the front.
main reads two lines of words, A and B (a line - is an empty list), and applies each operation to a copy of A. For the input
Tom George Peter Jean Jane
Tom George Michael Michelle Daniel
the program prints
A = [Tom, George, Peter, Jean, Jane], B = [Tom, George, Michael, Michelle, Daniel]
addAll changed the list: true -> [Tom, George, Peter, Jean, Jane, Tom, George, Michael, Michelle, Daniel]
removeAll changed the list: true -> [Peter, Jean, Jane]
retainAll changed the list: true -> [Tom, George]
A is untouched: [Tom, George, Peter, Jean, Jane] (5 elements)