Online Java Compiler By
JavaTpoint.com
import java.util.PriorityQueue; public class PriorityQueueRemoveExample1 { public static void main(String[] args) { PriorityQueue
Pqueue = new PriorityQueue
(); Pqueue.add("Amir"); Pqueue.add("Adam"); Pqueue.add("Chris"); Pqueue.add("Rafiq"); Pqueue.add("Ahana"); System.out.println("Queue before using remove() method :"); for (String value : Pqueue) { System.out.println(value); } System.out.println("Queue after using remove() method :" +Pqueue.remove("Chris")); for (String value : Pqueue) { System.out.println(value); } } }
Output