boolean retainAll(Collection c)
Retains only the elements in this collection that are contained in the specified collection (optional operation).
Retains only the elements in this collection that are contained in the specified collection (optional operation).
al1.add("abc");
al1.add("abc2");
al1.add("abc3"); ArrayList al2 = new ArrayList();
al2.add("abc");
al2.add("asdfd"); al1.retainAll(al2);
for(int i=0;i<al1.size();i++)
System.out.println(al1.get(i));Print out abc