Java ArrayBlockingQueue contains() Method

The contains() method of Java ArrayBlockingQueue() class returns true if the defined element is present in this queue.

Syntax:

Parameters:

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

Specified By:

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

  1. contains() method in interface BlockingQueue
  2. contains() method in interface Collection

Override:

The contains() method of class ArrayBlockinQueue is overrided by contains() method in class AbstractCollection.

Return Value

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

Example 1

Output:

Reema
Rahul
Rita
Ramesh
queue.contains( reema) will return true

Example 2

Output:

Student : Reema
Reema is present.