fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.lang.Math.*;
  4.  
  5. class Ideone{
  6. public static void main (String[] args) throws java.lang.Exception{
  7. int valor1 = 100;
  8. int valor2 = 22118400;
  9. int valor3 = 44954676;
  10.  
  11. int mul = Math.multiplyExact(valor1, valor2);
  12. int divisao = Math.floorDiv(mul, valor3);
  13. System.out.printf("A soma entre %d e %d resulta %d\n", valor1, valor2, mul);
  14. System.out.printf("A divisão entre %d e %d resulta %d", mul, valor3, divisao);
  15. }
  16. }
Runtime error #stdin #stdout #stderr 0.11s 320256KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.ArithmeticException: integer overflow
	at java.lang.Math.multiplyExact(Math.java:867)
	at Ideone.main(Main.java:11)