PriorityQueue in java | Java Collections Tutorial #08 | Java9s.com

preview_player
Показать описание
PriorityQueue in java is a data structure which sorts its elements based on the natural ordering. Unlike a normal queue which is First in First out model, priorityqueue places its elements at the appropriate position based on its priority.
It used the sorting criteria based on the outcome of the compareTo method.
In the priorityqueue video tutoria, i have explained about the queue and how it sorts its elements.
Download the example from
Рекомендации по теме
Комментарии
Автор

This is similar to TreeSet because TreeSet also sort the data. Is there any difference except TreeSet stores unique elements and Priority Queue stores all.

adityabhardwaj