The Java Program: Try_Block.java
1 class One_Exception extends Exception {
2 int argument;
3 public One_Exception (int i) { argument=i; }
4 }
5
6 class Another_Exception extends Exception {}
7
8 public class Try_Block {
9
10 public static void main (String argv[]) {
11
12
13
14 try {
15
16
17
18
19 if (1==0) {
20 throw new One_Exception (5);
21 } else {
22 throw new Another_Exception ();
23 }
24
25 } catch (One_Exception e) {
26
27 System.out.println (e.argument);
28
29 } catch (Another_Exception e) {
30
31 e.printStackTrace (System.err);
32
33 } finally {
34
35
36
37 }
38 }
39 }