Java – who has a useful mnemonic to implement a comparator?

Whenever I need to perform a comparison, I get stuck when I go back to - 1, when I need to go back to - 1, and I have to find

I mean, obviously - 1 is less, so that means the first is less than a second But as long as I say to myself, I get that "nag," are you sure? Feel I suspect that part of my confusion comes from other ways when I need a descending sort

What do you use to remember which is which?

Solution

comparator. compare(a,b) 0< ==> a< b

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>