Question: Given that the elements of a PriorityQueue are ordered according to natural ordering, and: 2. import java.util.*; 3. public class GetInLine { 4. public static

Given that the elements of a PriorityQueue are ordered according to natural ordering, and: 2. import java.util.*; 3. public class GetInLine { 4. public static void main(String[] args) { 5. PriorityQueue pq = new PriorityQueue(); 6. pq.add("banana"); 7. pq.add("pear"); 8. pq.add("apple"); 9. System.out.println(pq.poll() + " " + pq.peek()); 10. } 11. }

What is the result?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!