Java

Program to remove all the elements from a priority queue.

Program to remove all the elements from a priority queue.
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.clear();
  System.out.println("The New Priority Queue: " + P_queue);
 } 
}
Nikhil Juneja

Passionate software developer and technical contributor at TutorialsLink.