InterviewSolution
Saved Bookmarks
| 1. |
What is a priority queue in Java? |
|
Answer» When the objects are MEANT to be processed in order of priority, a PriorityQueue is used. A Queue is known to follow the First-In-First-Out method, however, there are occasions when the components of the queue must be handled in order of priority, which is where the PriorityQueue comes into PLAY. The priority HEAP is the foundation of the PriorityQueue. The members of the priority queue are ORDERED according to NATURAL ordering or by a Comparator provided at queue construction time. Serializable, Iterable<E>, Collection<E>, Queue<E> interfaces are implemented by the PriorityQueue class in Java. |
|