Datasets:

ArXiv:
License:
File size: 589 Bytes
c574d3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class ThrowDemo {
    public static void main(String[] args) {

        int a = 45;
        int b = 0;
        int rs;

        try {
            if (0 == b) // ? Can this condition be rewritten differently?
                throw (new ArithmeticException("Can't divide by zero."));
            else {
                rs = a / b;
                System.out.print("\n\tThe result is : " + rs);
            }
        } catch (ArithmeticException ex) {
            System.out.print("\n\tError : " + ex.getMessage());
        }

        System.out.print("\n\tEnd of program.");
    }

}