If I have a PriorityQueue made up of T objects, and T has a compareTo() method and implements comparable, but my PriorityQueue also takes a comparator as a parameter, what is my PriorityQueue going to look to for the ordering of its elements?
In other words, which one determines the priority of the objects? The compareTo() method or the provided comparator?
The documentation for the
comparatorparameter of the constructor states thatThis means that when a
comparatoris specified, the natural ordering established by thecompareTomethod is ignored.