arithmetic exception in java

Solutions on MaxInterview for arithmetic exception in java by the best coders in the world

showing results for - "arithmetic exception in java"
Aymen
23 Oct 2020
1It occurs when there is an error 
2in the aritchmatic logic. For 
3Example we can't divide int to 0.
4In this case it will throw arithmatic
5exception and we can handle with
6try catch block.(unchecked exception)
David
26 Aug 2017
1class Example1
2{
3   public static void main(String args[])
4   {
5      try{
6         int num1=30, num2=0;
7         int output=num1/num2;
8         System.out.println ("Result: "+output);
9      }
10      catch(ArithmeticException e){
11         System.out.println ("You Shouldn't divide a number by zero");
12      }
13   }
14}