-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinally_keyword.java
More file actions
36 lines (35 loc) · 842 Bytes
/
finally_keyword.java
File metadata and controls
36 lines (35 loc) · 842 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
27
28
29
30
31
32
33
34
35
36
package src.exception;
class finally_keyword {
static void demoA() {
try {
System.out.println("inside demoA");
throw new RuntimeException();
} finally {
System.out.println("demoA finally");
}
}
static void demoB() {
try {
System.out.println("inside demoB");
return;
} finally {
System.out.println("demoB finally");
}
}
static void demoC() {
try {
System.out.println("inside demoC");
} finally {
System.out.println("demoC finally");
}
}
public static void main(String[] args) {
try {
demoA();
} catch(Exception e) {
System.out.println("Exception: " + e);
}
demoB();
demoC();
}
}