Datasets:

ArXiv:
License:
File size: 554 Bytes
c574d3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/**
 * In this example, along with try block, we also enclose exception code in a
 * catch block.
 */
public class TryCatchExample5 {

    public static void main(String[] args) {
        try {
            int data1 = 50 / 0; // may throw exception
        }
        // handling the exception
        catch (Exception e) {
            System.out.println("Inside catch block:");
            // generating the exception in catch block
            int data2 = 50 / 0; // may throw exception
        }
        System.out.println("rest of the code");
    }
}