Q:

Java Program to insert a new element into a priority queue

0

Program to insert a new element into a priority queue.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.*;
public class demo1 
{
  public static void main(String[] args) 
  {
  PriorityQueue<String> P_queue=new PriorityQueue<String>();  
  P_queue.add("C#");
  P_queue.add("C++");
  P_queue.add("Java");
  P_queue.add("Python");
  P_queue.add("Ruby");
  System.out.println("Priority Queue: "+P_queue);
   
  P_queue.offer("Perl");
  System.out.println("The New Priority Queue: " + P_queue);
 } 
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now