public class TestClass { public static void main(String[] args) throws Exception { int a = Integer.MIN_VALUE; int b = -a; System.out.println( a+ " "+b); } }

because the max positive integer is not 2147483648 but 2147483647 because the 0 is also considered a positive int. so if you have an int of 2147483648, it is out of range. The couter of int goes: 2147483646 2147483647 -2147483648 -2147483647

This is explicity addressed in the Java Language Specification for the Unary Minus Operator -:

For integer values, negation is the same as subtraction from zero. The Java programming language uses two's-complement representation for integers, and the range of two's-complement values is not symmetric, so negation of the maximum negative int or long results in that same maximum negative number. Overflow occurs in this case, but no exception is thrown. For all integer values x, -x equals (~x)+1.

There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James