The containsAll() method of Java AbstractSequentialList is used to check whether two Collections contain the same elements or not. It takes one collection as a parameter and returns True if all of the elements of this collection is present in the other collection.
public boolean containsAll(Collection C)
Parameters: The parameter C is a Collection. This parameter refers to the collection whose elements occurrence is needed to be checked in this collection.
Return Value: The method returns True if this collection contains all the elements of other Collection otherwise it returns False.
Below programs illustrate the AbstractSequentialList.conatinsAll() method:
AbstractSequentialList 1: [Geeks, for, Geeks, 10, 20] AbstractSequentialList 2: [Geeks, for, Geeks, 10, 20] Both the collections same: true
AbstractSequentialList 1: [Geeks, for, Geeks] AbstractSequentialList 2: [10, 20] Are both collections same: false
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.