If an element from the passed-in collection is in the list multiple times, all instances are removed.
import java.util.ArrayList; import java.util.List; public class MainClass { public static void main(String args[]) throws Exception { List list = new ArrayList(); list.add("A"); list.add("A"); list.add("B"); list.add("B"); list.add("C"); list.add("C"); List list2 = new ArrayList(); list2.add("A"); list2.add("B"); list2.add("C"); list.removeAll(list2); System.out.println(list); } }
[]