You can use CollectionUtils.disjunction
to get all differences or CollectionUtils.subtract
to get the difference in the first collection.
Here is an example of how to do that:
var collection1 = List.of(1, 2, 3, 4, 5);
var collection2 = List.of(2, 3, 5, 6);
System.out.println(StringUtils.join(collection1, " , "));
System.out.println(StringUtils.join(collection2, " , "));
System.out.println(StringUtils.join(CollectionUtils.subtract(collection1, collection2), " , "));
System.out.println(StringUtils.join(CollectionUtils.retainAll(collection1, collection2), " , "));
System.out.println(StringUtils.join(CollectionUtils.collate(collection1, collection2), " , "));
System.out.println(StringUtils.join(CollectionUtils.disjunction(collection1, collection2), " , "));
System.out.println(StringUtils.join(CollectionUtils.intersection(collection1, collection2), " , "));
System.out.println(StringUtils.join(CollectionUtils.union(collection1, collection2), " , "));