-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAlwaysFinally.java
More file actions
40 lines (34 loc) · 995 Bytes
/
AlwaysFinally.java
File metadata and controls
40 lines (34 loc) · 995 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
37
38
39
40
package exceptions;
/**
* RUN:
* javac exceptions/AlwaysFinally.java && java exceptions.AlwaysFinally
* OUTPUT:
* First "try" begin
* Second "try" begin
* finally of second "try"
* catched FourException in first "try"
* finally of first "try"
*/
// import java.util.logging.*;
// import java.io.*;
public class AlwaysFinally {
public static void main(String[] args) {
System.out.println("First \"try\" begin");
try {
System.out.println("Second \"try\" begin");
try {
throw new FourException();
}
finally {
System.out.println("finally of second \"try\"");
}
}
catch(FourException e) {
System.out.println("catched FourException in first \"try\"");
}
finally {
System.out.println("finally of first \"try\"");
}
}
}
class FourException extends Exception {}