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).
Syntax:
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:
Example 1:
Output:
ConcurrentLinkedQueue: [Aman, Amar, Sanjeet, Rabi]
queue contains String "Aman" : true
queue contains String "Ram" : false
Example 2: