Certain mathematical comparisons will always return the same value, and should simply not be made.
These comparisons will always return false
:
-
comparing a
byte
with anint
orlong
constant that’s outside thebyte
range -
comparing an
int
with along
constant that’s outside theint
range -
comparing a value guaranteed to be negative with a one that’s guaranteed to be non-negative
These will always return true
:
-
comparing
aByte <= Byte.MAX_VALUE
andaByte >= Byte.MIN_VALUE
-
comparing
anInt <= Integer.MAX_VALUE
andanInt >= Integer.MIN_VALUE
-
comparing
aLong <= Long.MAX_VALUE
andaLong >= Long.MIN_VALUE