intersection/union of arraylists in java

list.retainAll(anotherList) // for intersection
list.addAll(anotherList) // union