What will be the output of the following code?

Last Updated :
Discuss
Comments

What will be the output of the following code?

Java
import java.util.*;
public class Test {
    public static void main(String[] args) {
        Queue<Integer> queue = new PriorityQueue<>();
        queue.add(30);
        queue.add(10);
        queue.add(50);
        queue.add(20);
        System.out.println(queue.poll());
    }
}


10

30

50

20

Share your thoughts in the comments