Common elements in two lists

后端 未结 14 1154
无人共我
无人共我 2020-11-22 12:22

I have two ArrayList objects with three integers each. I want to find a way to return the common elements of the two lists. Has anybody an idea how I can achiev

14条回答
  •  时光说笑
    2020-11-22 12:42

    consider two list L1 ans L2

    Using Java8 we can easily find it out

    L1.stream().filter(L2::contains).collect(Collectors.toList())

提交回复
热议问题