containsAll() method: This containsall in java method utilizes to check the “all elements of given collection are present in another collection or not. It returns only boolean value. If the given collection exists in collection, then it returns true otherwise false.
Where, c is the collection which you want to check in this collection.
return type: Its return type is boolean. It can return either true or false.
How containsAll() method can work: This java method checks the given collection in the current collection. If the collection contains all elements of specified collection it returns true otherwise false.
This containsall in Java method can throw different types of exceptions:
ClassCastException, If the class of the specified element prevents it from being added to this collection.
NullPointerException, If the specified element is null and the collection does not allow null elements.