PriorityQueue API does not make promises for this situation:
The head of this queue is the smallest element relative to the specified order. If several elements are attached to the smallest value, the head is one of these elements - the bonds break arbitrarily. Queue search, delete, view, and item access the item at the head of the queue.
But this is easy to verify. Add toString to Pair
@Override public String toString() { return key + " " + value; }
and print the survey results
Pair pair = queue.poll();
he prints
1 1
source share