I am studying the source of the OpenJDK.
My attention was attracted by the methods Byte.compare()
and Integer.compare()
:
public static int Byte.compare(byte x, byte y) {
return x-y;
}
public static int Integer.compare(int x, int y) {
return (x < y) ? -1 : ((x == y) ? 0 : 1);
}
Why do the methods Byte.compare()
and Integer.compare()
have different implementations?
return (x < y) ? -1 : ((x == y) ? 0 : 1);
– Phoebe