According to the documentation the method returns an int greater than 0 if it is greater or less than 0 if it is less, but looking at the method you see that it always returns -1, 0, 1.
Returns: the value 0 if x == y; a value less than 0 if x < y; anda value greater than 0 if x > y
And then the code:
/**
* Compares two {@code int} values numerically.
* The value returned is identical to what would be returned by:
* <pre>
* Integer.valueOf(x).compareTo(Integer.valueOf(y))
* </pre>
*
* @param x the first {@code int} to compare
* @param y the second {@code int} to compare
* @return the value {@code 0} if {@code x == y};
* a value less than {@code 0} if {@code x < y}; and
* a value greater than {@code 0} if {@code x > y}
* @since 1.7
*/
public static int compare(int x, int y) {
return (x < y) ? -1 : ((x == y) ? 0 : 1);
}
So my question is, when you implement a comparable, do you have to check that you get -1,0,1 or Integers greater than, equal to or less than 0?