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

前端 未结 8 2194
生来不讨喜
生来不讨喜 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条回答
  •  时光说笑
    2020-12-03 01:36

    For comaparing a list or set we can use Arrays.equals(object[], object[]). It will check for the values only. To get the Object[] we can use Collection.toArray() method.

提交回复
热议问题