Why not:
return o2.compareTo(o1);because the o2 vs o1 is easy to miss, while the -1 makes it obvious i'm intentionally reversing. my .02
Not if you give them more descriptive names
No, you can't. In particular -1 * Integer.MIN_VALUE == Integer.MIN_VALUE.
Re:Java for Everything
by organsnyder on Friday December 05, 2014 @03:36PM
(#8706745)
That would probably never matter in practice, though—I've rarely seen compareTo() return anything other than -1, 0, or 1; certainly never anything approaching MAX/MIN_VALUE. Still, bravo for considering all of the edge cases.
it could also be accomplished with