CopyOnWriteArraySet equals() method in Java
The equals(Object O) method of CopyOnWriteArraySet compares the specified object with this set for equality. Returns true if the specified object is the same object as this object, or if it is also a Set and the elements returned by an iterator over the specified set are the same as the elements returned by an iterator over this set. More formally, the two iterators are considered to return the same elements if they return the same number of elements and for every element e1 returned by the iterator over the specified set, there is an element e2 returned by the iterator over this set such that (e1==null ? e2==null : e1.equals(e2)).
public boolean equals(Object O)
Parameters: This function accepts a mandatory parameter Object O which is the Object with which the CopyOnWriteArraySet is to be compared.
Return Value: The function returns true if the compared object is equal to this Set.
CopyOnWriteArraySet 1: [32, 67, 98, 100] CopyOnWriteArraySet 2: [32, 67, 98, 100] Both are Equal
CopyOnWriteArraySet 1: [32, 67, 98, 100] CopyOnWriteArraySet 2: [3, 6, 9, 10] Both are not Equal
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.