Online Java Compiler By
JavaTpoint.com
import java.util.PriorityQueue; public class PriorityQueuePollExample1 { public static void main(String[] args) { PriorityQueue
Pqueue = new PriorityQueue
(); Pqueue.add("Ramesh"); Pqueue.add("Yasir"); Pqueue.add("Mark"); Pqueue.add("Robert"); String val = Pqueue.poll(); System.out.println("Head of queue is: "+val); System.out.println("Queue after using poll() method : "); for(String xyz : Pqueue) { System.out.println(xyz); } } }
Output