CopyOnWriteArraySet containsAll() method in Java with Example
The containsAll() method of Java CopyOnWriteArraySet is used to check whether two sets contain the same elements or not. It takes one set as a parameter and returns True if all of the elements of this set is present in the other set.
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. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.
public boolean containsAll(Collection C)
Parameters: The parameter C is a Collection. This parameter refers to the set whose elements occurrence is needed to be checked in this set.
Return Value: The method returns True if this set contains all the elements of other set otherwise it returns False.
Below programs illustrate the CopyOnWriteArraySet.containsAll() method:
CopyOnWriteArraySet 1: [Geeks, for, 10, 20] CopyOnWriteArraySet 2: [Geeks, for, 10, 20] Does set 1 contains set 2: true
CopyOnWriteArraySet 1: [Geeks, for, Geeks, 10, 20] CopyOnWriteArraySet 2: [Geeks, for, Geeks, 10, 20] Does set 1 contains set 2: true
CopyOnWriteArraySet 1: [Geeks, for] CopyOnWriteArraySet 2: [10, 20] Does set 1 contains set 2: false