Snippet to remove a element from any arraylist based on the matching condition is as follows:
List<String> nameList = new ArrayList<>();
nameList.add("Arafath");
nameList.add("Anjani");
nameList.add("Rakesh");
Iterator<String> myItr = nameList.iterator();
while (myItr.hasNext()) {
String name = myItr.next();
System.out.println("Next name is: " + name);
if (name.equalsIgnoreCase("rakesh")) {
myItr.remove();
}
}