priorityqueue poll

Java
// Java code to illustrate poll() 
// poll() is basically a pop method that pops the least prioritized element.
import java.util.*; 
  
public class PriorityQueueDemo { 
    public static void main(String args[]) 
    { 
        // Creating an empty PriorityQueue 
        PriorityQueue<String> queue = new PriorityQueue<String>(); 
  
        // Use add() method to add elements into the Queue 
        queue.add("Welcome"); 
        queue.add("To"); 
        queue.add("Geeks"); 
        queue.add("For"); 
        queue.add("Geeks"); 
  
        // Displaying the PriorityQueue 
        System.out.println("Initial PriorityQueue: " + queue); 
  
        // Fetching and removing the element at the head of the queue 
        System.out.println("The element at the head of the"
                           + " queue is: " + queue.poll()); 
  
        // Displaying the Queue after the Operation 
        System.out.println("Final PriorityQueue: " + queue); 
    } 
} 

Source

Also in Java: