System.out.println(Integer.MAX_VALUE + 1 == Integer.MIN_VALUE);
is true.
I understand that integer in Java is 32 bit and can\'t go above 23
Because the integer overflows. When it overflows, the next value is Integer.MIN_VALUE
. Relevant JLS
If an integer addition overflows, then the result is the low-order bits of the mathematical sum as represented in some sufficiently large two's-complement format. If overflow occurs, then the sign of the result is not the same as the sign of the mathematical sum of the two operand values.
The same reason why the date changes when you cross the international date line: there's a discontinuity there. It's built into the nature of binary addition.