Datasets:

ArXiv:
License:
File size: 553 Bytes
c574d3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
 * Here, we handle the exception using the parent class exception in the catch
 * block. We also display a custom message from the catch block
 */
public class TryCatchExample4 {

    public static void main(String[] args) {
        try {
            int data = 50 / 0; // may throw exception
        }
        // handling the exception by using Exception class
        catch (Exception e) {
            System.out.println("Can't divided by zero");
            e.printStackTrace();
        }
        System.out.println("rest of the code");
    }

}