Here is the answer with an example
import java.util.*;
public class myArrLst {
public static void main(
String[] ars) {
ArrayList arlst1 = new ArrayList();
ArrayList arlst2 = new ArrayList();
//lets add some elements
arlst2.add("4"); arlst2.add("5"); arlst2.add("6"); //Line X
arlst1.add("4"); arlst1.add("5"); arlst1.add("6");
arlst1.add(arlst1);
System.out.println("Size of list 1 " + arlst1.size());
System.out.println("Size of list 2 " + arlst2.size());
//Now the trick. There is recusrion that is build inside removeAll
arlst1.removeAll((Collection)arlst2); //removeAll belongs to interface
//Collection
System.out.println("Size of list 1 after removal" + arlst1.size());
System.out.println("Size of list 2 after removal" + arlst2.size());
}
}
//To see what happens in Line X change 4,5,6 to 1,2 & 3 respectively.
Hope this helps.
Caesar