How Best to Compare Two Collections in Java and Act on Them?

前端 未结 8 2175
生来不讨喜
生来不讨喜 2020-12-03 00:41

I have two collections of the same object, Collection oldSet and Collection newSet. The required logic is as follow:

8条回答
  •  Happy的楠姐
    2020-12-03 01:27

    I think the easiest way to do that is by using apache collections api - CollectionUtils.subtract(list1,list2) as long the lists are of the same type.

提交回复
热议问题