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(1);
        prq.add(2);
        prq.add(1);
        prq.add(64);
        prq.add(1);

        System.out.println(prq);

        // create arr1
        Integer[] arr1 = new Integer[5];

        // use toArrsy() method
        Integer[] arr2 = prq.toArray(arr1);

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

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