priority queue and peek, poll methods


When we use priority queue and whar are the uses of peek, poll methods. How it is different from regular queue and dequeue. please advise
Who is Participating?
For a java.util.PriorityQueue object, peek retrieves but does not remove the head of the queue, poll retrieves and removes the head of the queue.
The elements of the priority queue are ordered according to their value, while the elements of a regular queue are ordered by which was inserted first.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.