How can I return the difference between two lists?

后端 未结 10 656
终归单人心
终归单人心 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:51

    You can convert them to Set collections, and perform a set difference operation on them.

    Like this:

    Set ad = new HashSet(a);
    Set bd = new HashSet(b);
    ad.removeAll(bd);
    

提交回复
热议问题