forked from PrajaktaSathe/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNestedTry.java
More file actions
26 lines (23 loc) · 800 Bytes
/
NestedTry.java
File metadata and controls
26 lines (23 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package nestedBlocks;
public class NestedTry {
public static void main(String[] args) {
int a = 20, b;
int ch[] = new int[20];
try {
b = a / 0;
try {
System.out.println("Value of b = " + b);
} catch (Exception e) {
System.out.println("Inner block Exception occured!");
}
} catch (Exception e) {
System.out.println("Outer block exception occured!");
} finally {
System.out.println("Quit");
System.out.println("This block will always execute!");
}
// finally block can be used to catch any exception
}
}
/* Note: Inner catch will use the outer catch block but outer catch will not use inner catch block exception
* */