You can use retainAll method:
columnsOld.retainAll (columnsNew);
Answer from Roman on Stack OverflowYou can use retainAll method:
columnsOld.retainAll (columnsNew);
Using Google's Guava library:
Sets.intersection(Sets.newHashSet(setA), Sets.newHashSet(setB))
Note: This is much more efficient than naively doing the intersection with two lists: it's O(n+m), versus O(n×m) for the list version. With two million-item lists it's the difference between millions of operations and trillions of operations.
intersection for multiple lists - Java Programming
Finding the XOR between multiple lists of no overlapping time intervals (Java)
sets - Is there a simple way to perform the opposite of intersection on two lists? - Mathematica Stack Exchange
How to find the intersection of two linked lists?
Does any one have any elegant solution for finding the XOR between two lists of time intervals, preferably in Java? You can assume that, within each list, the time intervals are non-overlapping, but it is not safe to assume that between the two lists they are non-overlapping. I’ve been struggling with it the past couple of days.
There is probably a build-in command for this, but with over 6,000 commands, hard to search now. But you could try
inter=Intersection[list1,list2];
Complement[Union[list1,list2],inter]

a = {1, 2, 4, 7, 9};
b = {1, 4, 9, 10, 11};
Since V 13.1 we have SymmetricDifference, UniqueElements and
DeleteElements
SymmetricDifference[a, b]
{2, 7, 10, 11}
UniqueElements[{a, b}]
{{2, 7}, {10, 11}}
{DeleteElements[a, b], DeleteElements[b, a]}
{{2, 7}, {10, 11}}