-
Notifications
You must be signed in to change notification settings - Fork 0
/
Close.java
30 lines (27 loc) · 855 Bytes
/
Close.java
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
// KFH-Close/Close.java
public class Close {
public static void main(String... args) {
try(Closeable cB = new Closeable("B");
Closeable cA = new Closeable("A") )
{
cB.doSomething(1);
cA.doSomething(1);
} catch (Exception e) {
System.out.println("In catch_1");
e.printStackTrace();
for(Throwable t : e.getSuppressed())
System.out.println(t);
}
try(Closeable cX = new Closeable("X");
Closeable cA = new Closeable("A") )
{
cA.doSomething(9);
cX.doSomething(1);
} catch (Exception e) {
System.out.println("In catch_2");
e.printStackTrace();
for(Throwable t : e.getSuppressed())
System.out.println(t);
}
}
}