How can I return the difference between two lists?

后端 未结 10 687
终归单人心
终归单人心 2020-11-27 03:49

I have two array lists e.g.

List a;
contains : 10/10/2014, 10/11/2016

List b;
contains : 10/10/2016

How can i do

10条回答
  •  心在旅途
    2020-11-27 04:26

    If you only want find missing values in b, you can do:

    List toReturn = new ArrayList(a);
    toReturn.removeAll(b);
    
    return toReturn;
    

    If you want to find out values which are present in either list you can execute upper code twice. With changed lists.

提交回复
热议问题