Online Java Compiler By
JavaTpoint.com
import java.util.PriorityQueue; class Patients implements Comparable{ String name; public Patients(String name) { this.name = name; } public String toString(){ return this.name; } @Override public int compareTo(Object o) { return 0; } } public class PriorityQueueRemoveExample3 { public static void main(String[] args) { PriorityQueue
Pqueue = new PriorityQueue
(); Patients p1 =new Patients("Amar"); Patients p2 =new Patients("Mukta"); Patients p3 =new Patients("Aloke"); Pqueue.add(p1); Pqueue.add(p2); Pqueue.add(p3); System.out.println("Patients are : "+Pqueue); Pqueue.remove(p2); System.out.println("Patients left : "+Pqueue); } }
Output