The basic use of Queue class is to provide a data structure which allows storing objects in a First in First out(FIFO) format. But sometimes one wants to maintain the ordering, based on some other metric. This is exactly the purpose of PriorityQueue, another Queue implementation. You provide it a Comparator, and it does the …