Why is it that I can add 1 to already a max value of int? The output of this code is -2147483648. Isn't this only possible if type of biggerValue is a long? Guess not?
public class Test {
public static void main (String[] args) {
AddOne addOne = new AddOne();
System.out.println("The value of bigger is " + addOne.plusOne());
}
}
class AddOne {
public long plusOne() {
int value = Integer.MAX_VALUE;
int biggerValue = value + 1;
return biggerValue;
}
}