Search code examples
javaarraylistsubsetcontainment

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


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


Solution

  • Use Collection.containsAll():

    boolean isSubset = listA.containsAll(listB);