The more worrisome thing about equality in Java is that there are integer values for which
a == a
is true, while a + 1 == a + 1
evaluates to false.(edit: precision)
a == a
is true, while a + 1 == a + 1
evaluates to false.(edit: precision)
Integer b = a+1;
Integer c = a+1;
b==c
Which by default returns true for a=126 but false for a=127. A bad situation for sure, but thankfully pretty much every static analysis tool will spot that.