Is there a difference between the two? If so, what is it?
When I used them for a priority queue, the both sort it the same way.
If you use a good IDE, it's very easy to see the source code of the Java Runtime Library methods. E.g. in Eclipse you press F3 when cursor is on the method.
If you do that on the Comparator.reverseOrder()
method, you'll see:
public static <T extends Comparable<? super T>> Comparator<T> reverseOrder() {
return Collections.reverseOrder();
}
Conclusion: They are exactly the same.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With