Java 8 Lambda - Intersection of Two Lists

后端 未结 3 1035
你的背包
你的背包 2020-12-05 06:11

I am trying to find intersection of two lists based on some condition and doing some steps. Couldn\'t find a way to do it (in learning stage) :)



        
3条回答
  •  旧时难觅i
    2020-12-05 07:03

    The simplest approach is this:

    List intersect = list1.stream()
                             .filter(list2::contains)
                             .collect(Collectors.toList());
    

提交回复
热议问题