Java Integers Min_Value negative then compare
问题 I have a test tomorrow and I cant understand my books explanation, I appreciate the help: public class TestClass{ public static void main(String[] args) throws Exception{ int a = Integer.MIN_VALUE; int b = -a; System.out.println( a+ " "+b); } } Output: -2147483648 -2147483648 Why does this print 2 negative numbers of the same magnitude and not a positive and negative? 回答1: Because of silent integer overflow: Integer.MIN_VALUE is -2^31 and Integer.MAX_VALUE is 2^31-1 , so -Integer.MIN_VALUE is