且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

有没有办法找到多个列出了常见的元素呢?

更新时间:2022-12-12 22:53:11

您可以转换列表来台,然后用 Set.retainAll 方法不同之间的交叉集。
一旦你所有的相交集,你会留下共同的元素,您可以将结果集返回到列表中。

You can transform the lists to sets, and then use Set.retainAll method for intersection between the different sets. Once you intersect all sets, you are left with the common elements, and you can transform the resulting set back to a list.