Answer the question
In order to leave comments, you need to log in
Is there a function in java to remove identical elements in a list?
Good afternoon. I have 2 lists (List), can I remove from the first list all the elements that are in the second? Or rather, is there such a function in java so as not to write a bicycle yourself?
Answer the question
In order to leave comments, you need to log in
List<String> list1 = new ArrayList<>();
List<String> list2 = new ArrayList<>();
list1.add("1");
list1.add("2");
list1.add("3");
list2.add("3");
list2.add("4");
list2.add("5");
list1.removeAll(list2);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question