intersection union and difference of arraylists in java
2013-12-01azim58 - intersection union and difference of arraylists in java
for search purposes: union intersection subtraction of lists or sets in
java
use the retain all, remove all, and addall methods
Example
ArrayList list1 = useful_tools.stringWithCommasToArrayList("2,5,8");
ArrayList list2 = useful_tools.stringWithCommasToArrayList("3,5,9");
list1.retainAll(list2);
list1.removeAll(list2);
list1.addAll(list2);
System.out.println(list1);