ArrayList<String> languages = new ArrayList<String>();
languages.add("Java");
languages.add("PHP");
languages.add("HTML");
languages.add("Python");
languages.add("PhotoShop");
System.out.println(languages); //[Java, PHP, HTML, Python, PhotoShop]
ArrayList<String> front_end = new ArrayList<String>();
front_end.add("HTML");
front_end.add("PhotoShop");
front_end.add("JavaScript");
languages.removeAll(front_end);
System.out.println(languages); //[Java, PHP, Python]
In above code we created a second lsit front_end, in this list two elements HTML and PhtoShop are matching with elements of our main ArrayList languages. So removeAll() has removed these two matching elements from our main list languages.
As we get boolean output, we can use if else to show messages.
Note that we will get true output even if there is only one matching removal. If no matching element is there ( no removal ) then we will get false as output.
More than one matching elements
What happens if there are more than one matching elements in the main list ?