What will be the output of following Java quiz on PriorityQueue ?
PriorityQueue keeps elements sorted and it can have duplicates.
add() and offer() methods both offer same functionality.
poll() method removes the first element in queue and returns it, while peek() method returns the first element without removing it.
Correct answer : “Apple Apple Nokia Nokia”
You may also like
© 2016, www.topjavatutorial.com. All rights reserved. On republishing this post, you must provide link to original post