Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.PriorityQueue;

public class Main {
    public static void main(String args[]) {

        PriorityQueue<Integer> prq = new PriorityQueue<Integer>();

        // insert values in the queue
        prq.add(6);
        prq.add(9);
        prq.add(5);
        prq.add(64);
        prq.add(6);

        System.out.println(prq);

        // get objects from the queue
        Object[] arr = prq.toArray();

        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
    }
}