ConcurrentLinkedQueue contains() method in Java
The contains() method of ConcurrentLinkedQueue returns true if ConcurrentLinkedQueue contains the object o, passed as parameter. This method returns true if and only if this ConcurrentLinkedQueue contains at least one element e which is equal to object o passed as parameter i.e. o.equals(e).
public boolean contains(Object o)
Parameter: This method takes a single parameter O which represents object to check whether ConcurrentLinkedQueue contains the specified object.
Returns: This method returns true if this ConcurrentLinkedQueue contains the object.
Below programs illustrate contains() method of ConcurrentLinkedQueue:
ConcurrentLinkedQueue: [Aman, Amar, Sanjeet, Rabi] queue contains String "Aman" : true queue contains String "Ram" : false
ConcurrentLinkedQueue: [4353, 7824, 78249, 8724] queue contains Number 78249 : true queue contains Number 9876: false
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.