fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int maxAgain = 2147483647+1;
  13. System.out.println(maxAgain);
  14.  
  15. try
  16. {
  17. int result = Math.addExact( 2_147_483_647 , 1 ) ;
  18. System.out.println( result ) ;
  19. }
  20. catch ( ArithmeticException e )
  21. {
  22. System.out.println( e ) ;
  23. }
  24.  
  25. // int maxAgain1 = 2147483648 ;
  26. // System.out.println(maxAgain1);
  27. }
  28. }
Success #stdin #stdout 0.07s 32584KB
stdin
Standard input is empty
stdout
-2147483648
java.lang.ArithmeticException: integer overflow