Intersection and union of ArrayLists in Java

后端 未结 24 2508
离开以前
离开以前 2020-11-22 06:05

Are there any methods to do so? I was looking but couldn\'t find any.

Another question: I need these methods so I can filter files. Some are AND filter

24条回答
  •  轮回少年
    2020-11-22 06:38

    Unions and intersections defined only for sets, not lists. As you mentioned.

    Check guava library for filters. Also guava provides real intersections and unions

     static  Sets.SetViewunion(Set set1, Set set2)
     static  Sets.SetView intersection(Set set1, Set set2)
    

提交回复
热议问题