Answers for "addExact, Overflow"

0

addExact, Overflow

int value = Integer.MAX_VALUE-1;
for(int i = 0; i < 4; i++) {
    System.out.println(value);
    value = Math.addExact(value, 1);
}
Posted by: Guest on August-23-2021
0

addExact, Overflow

2147483646
2147483647
Exception in thread "main" java.lang.ArithmeticException: integer overflow
	at java.lang.Math.addExact(Math.java:790)
	at baeldung.underoverflow.OverUnderflow.main(OverUnderflow.java:115)
Posted by: Guest on August-23-2021

Browse Popular Code Answers by Language