Java LinkedBlockingDeque contains() Method

The contains() method is used to check the presence of the specified element in the deque. If the element is present in the deque, then this method returns true otherwise it returns false.

Syntax:

Parameters:

o - this is the object that is to be checked for occurrence in this deque.

Specified By:

The contains() method of LinkedBlockingDeque class is specified by:

  • contains() method in interface Collection<E>.
  • contains() method in interface BlockingQueue<E>.
  • contains() method in interface BlockingDeque<E>.
  • contains() method in interface Deque<E>.

Override:

The contains() method of class LinkedBlockingDeque is overridden by contains() method in class AbstractCollection<E>.

Return Value:

The contains() method returns true if the defined element is present in this deque.

Example 1

Test it Now

Output:

Himanshu
Rahul
Rita
Ramesh
queue.contains( Himanshu) will return true

Example 2

Test it Now

Output:

Harshit is present.





Latest Courses