0

Today I met some Java code, but I cannot understand them, please see below code:

    int a = Integer.MAX_VALUE;
    int b = Integer.MAX_VALUE;

    int sum = a + b; 
    System.out.println("a="+a+",b="+b+",sum="+sum);

And the output is:

    a=2147483647,b=2147483647,sum=-2

My question is why sum = -2?

Coinnigh
  • 611
  • 10
  • 18

0 Answers0