PriorityQueue class contains(Object o)method example

Returns true if this queue contains the specified element.


PriorityQueue class contains(Object o)method example. This example shows you how to use contains(Object o)method.This method Returns true if this queue contains the specified element.

Here is the code:-

/**
 * @Program that Returns true if this queue contains the specified element.
 * Contains.java 
 * Author:-RoseIndia Team
 * Date:-28-May-2008
 */
import java.util.*;

public class Contains {

    public static void main(String[] args) {
//Creating a  PriorityQueue   
        PriorityQueue p = new PriorityQueue();
//Adding element to the queue
        p.add("Girish");
        p.add("Tewari");
        boolean b = p.contains("Girish");
        System.out.println("Contains: " + b);
        boolean b1 = p.contains("Komal");
        System.out.println("Contains: " + b1);
    }
}

Output of the program:-
Contains: true
Contains: false

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US