Menu
Question Index
...

Write a program to remove the first element from the given input by using one of the Queue interface methods.
Note that the elements in Queue by default sorted in ascending order.

Input (PriorityQueue) Output (PriorityQueue)
[Lion, Tiger, Cat, Rabbit, Mouse] [Lion, Mouse, Rabbit, Tiger]
[Rose, Jasmine, Lotus, Peacock, Cassia] [Jasmine, Peacock, Lotus, Rose]
[Suman, Sekhar, Rohan, Sukumar, Praneeth, Prakash] [Praneeth, Rohan, Sekhar, Suman, Sukumar]
null null


import java.util.*;
class RemoveFirstElementInQueue
{
    public static void main(String s[])
    {
        PriorityQueue<String> input = new PriorityQueue<String>();
        input.add("Ramesh");
        input.add("Sujan");
        input.add("Ravi");
        input.add("Ramu");
        input.add("Krishna");
        System.out.println("The elements after removed first element: " + removeFirstElelment(input));

    }


    public static PriorityQueue<String> removeFirstElelment(PriorityQueue<String> input) {
    }

}

Doubts

Problems

Topic: Java ArrayDeque Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App