How to use arithmetic exception handling in Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
        try {  
            int n = 43 / 0;  
        } catch (ArithmeticException e) {
            System.out.println(e);
        }  
        System.out.println("After Exception");  
  }  
}


/*
run:

java.lang.ArithmeticException: / by zero
After Exception

*/

 



answered Jun 29, 2019 by avibootz

Related questions

4 answers 539 views
539 views asked Dec 11, 2020 by avibootz
1 answer 544 views
1 answer 381 views
1 answer 263 views
2 answers 392 views
...