thats because when you give any number directly, like num1 + num2 , they are taken as integers, and since the value is out of bounds in this case, you will get either 0 or another output depending on the input.
You can easily solve this problem by choosing
long mult = 2147483647; mult += 2147483647; mult += 2; System.out.println(mult);
Manoj source share