Biblioteca Java - Blame information for rev 36
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
36 | mihai | 1 | |
2 | public class TestMyException { | ||
3 | public static int f(int x, int y) throws MyException { | ||
4 | if(x==0&&y==0) | ||
5 | throw new MyException(); | ||
6 | else | ||
7 | return x + y; | ||
8 | } | ||
9 | |||
10 | public static void g() throws MyException2 { | ||
11 | // System.out.println("Exceptie in g()"); | ||
12 | throw new MyException2("aruncata din g()"); | ||
13 | } | ||
14 | |||
15 | public static void main(String[] args){ | ||
16 | |||
17 | System.out.println("PAS 1"); | ||
18 | |||
19 | try { | ||
20 | int x = 10; | ||
21 | System.out.println("PAS 2"); | ||
22 | f(0,0); | ||
23 | System.out.println("PAS 3"); | ||
24 | g(); | ||
25 | System.out.println("PAS 4"); | ||
26 | } catch(MyException e) { | ||
27 | System.out.println("TRATARE EROARE"); | ||
28 | e.printStackTrace(); | ||
29 | } catch(MyException2 e){ | ||
30 | System.out.println("TRATARE EROARE 2"); | ||
31 | e.printStackTrace(); | ||
32 | } finally{ | ||
33 | System.out.println("PAS 5"); | ||
34 | } | ||
35 | |||
36 | System.out.println("PAS 6"); | ||
37 | /*try { | ||
38 | g(); | ||
39 | } catch(MyException e) {e.printStackTrace();}*/ | ||
40 | |||
41 | } | ||
42 | } | ||
43 | |||
44 | class MyException extends Exception { | ||
45 | public MyException() {} | ||
46 | public MyException(String msg) { | ||
47 | super(msg); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | class MyException2 extends Exception { | ||
52 | public MyException2() {} | ||
53 | public MyException2(String msg) { | ||
54 | super(msg); | ||
55 | } | ||
56 | } |