Online Java Compiler By
JavaTpoint.com
import java.util.PriorityQueue; public class PriorityQueueToArrayExample3 { 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); Integer[] a = new Integer[5]; Integer[] b = Pqueue.toArray(a); System.out.print("Elements : "); for (int i = 0; i
a[j]) { temp = b[i]; b[i] = b[j]; b[j] = temp; } } } for (int i = 0; i
Output