Java PriorityQueue contains() Method

The contains() method of PriorityQueue class returns true if the specified element is present in this queue.

Syntax

Parameter

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

Specified By

The contains() method of PriorityQueue class is specified by contains() method in interface Collection<E>

Override

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

Return Value

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

Example 1

Output:

Mira
Rajesh
Ram
Sham
Ram is present

Example 2

Output:

Q. Enter a prime no btw 1-10.
Ans 6
Incorrect answer!