How to check whether the elements of an ArrayList are all contained in another ArrayList

前端 未结 2 755
-上瘾入骨i
-上瘾入骨i 2020-12-18 18:35

How can I easily check to see whether all the elements in one ArrayList are all elements of another ArrayList?

相关标签:
2条回答
  • 2020-12-18 19:03

    There is a containsAll method in all collections.

    0 讨论(0)
  • 2020-12-18 19:19

    Use Collection.containsAll():

    boolean isSubset = listA.containsAll(listB);
    
    0 讨论(0)
提交回复
热议问题