If I have two ArrayList list and toremove , and I want to delete all the objects on list that are equals to objects on toremove. But only once (one instance of the object). How can I achieve that in Java ? Do I have to manually loop through all toremove objects and delete it if it in list?
I have tried .removeAll(toremove); but it deletes every instance if objects.
for example, if i have book1 book1 book2 book3, and my toRemove list is book1 book2. the output will be book1 book3.
private List<Book> removeList(List<Book> initial,List<Book> toremove) {
List<Book> list=initial;
for (Book book : List) {
}
return List;
}
List List=Initialmakes for some very confusing code