As other answers said, you need to override equals
and hashCode
.
You can use Collection.removeAll method.
First you need to wrap the listNew
into a HasSet which ensure the uniquness.
Collection<User> newUniques = new HashSet<User>();
newUniques.addAll(listNew);
newUniques.removeAll(listOld);
Now your newUniques
will have desired results.
If you can use the apache commons, ListUtils.removeAll(listNew, listOld)
is another option.