What is the function of the contains(Object o) and containsAll(Collection c) methods from the Collection interface?

What is the function of the contains(Object o) and containsAll(Collection<?> c) methods from the Collection interface?



Answer: contains() returns true if the object is found in the collection, while containsAll returns true if all elements of the collection are found inside the original. For both of these methods, all elements and objects should implement the equals() method. In the case of sets, the hashCode() method should be implemented as well.


Learn More :

Data Structures

Learn More Multiple Choice Question :