contains() method: This contain method is used to check the given element is present in the collection or not. It returns only boolean value. If the given element exists in collection, then it returns true otherwise false.
boolean contains(Object obj);
obj is the element that you want to check in the collection.
return type: Its return type is boolean. It can return either true or false.
How contains() method can work: This method checks the given element in collection. If the collection contains the specified element it returns true otherwise false.
This 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.