Online Java Compiler By
JavaTpoint.com
import java.util.PriorityQueue; public class PriorityQueueToArrayExample2 { public static void main(String[] args) { PriorityQueue
Pqueue = new PriorityQueue
(); Pqueue.add(8); Pqueue.add(5); Pqueue.add(17); Pqueue.add(80); Pqueue.add(2); System.out.println(Pqueue); Object[] a = Pqueue.toArray(); for (int i = 0; i
a[j]) { temp = a[i]; a[i] = a[j]; a[j] = temp; } } } for (int i = 0; i
Output