PriorityQueue extends
AbstractQueue and implements the Queue interface. It creates a queue that is prioritized based on the comparator.
The elements of the priority queue are ordered according to their natural ordering, or by a
Comparator provided at queue construction time, depending on which constructor is used. PriorityQueue is declared as follows:
class PriorityQueue< E >
where E specifies the type of the object that is stored in a queue.
PriorityQueue has six constructors which are defined below:
Comparator< ? super E > comparator()
To add or remove elements to the PriorityQueue , the methods defined by Queue interface must be implemented:
PriorityQueueDemo CODE import java.util.*; OUTPUT 1 DESCRIPTION In this example, a THINGS TO TRY
Dependent Topics :
|