The Iterator provided in method iterator() is not guaranteed to traverse the elements of the priority queue in any particular order. If you need ordered traversal, consider using Arrays.sort(pq.toArray()).
So printing the queue doesn't print the items in the order that you would get them if you retrieved them from the queue one at a time.
The docs say that this priority queue is based on a priority heap. The docs also don't mention that toString() is overridden by this class. PriorityQueue actually uses the toString method from AbstractCollection.
I'm going to guess that therefore toString() doesn't bother to print the elements in order, it just uses some arbitrary internal order dependent on the heap. If you want to print the elements in order, you'll have to use an Iterator or something similar and print them yourself.