-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMain.java
executable file
·79 lines (73 loc) · 2.22 KB
/
Main.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Main.java
*
* Created on 17 ëèïíÿ 2008, 13:07
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package finallypkg;
/**
*
* @author Technik
*/
public class Main {
public static int get_value(int value){
try{
System.out.println("try begin");
if(value>0){
throw new Exception("");
}
System.out.println("try end");
}catch(Exception ex){
System.out.println(" catch begin");
return value;
}finally{
System.out.println(" finally begin");
return value+1;
}
}
public static int get_value_2(int value) throws Exception{
try{
System.out.println("try begin");
if(value>0){
System.out.println("throw Exception");
throw new Exception("get_value_2 exception");
}
System.out.println("try end");
}catch(Exception ex){
System.out.println(" catch begin");
// äàííîå èñêëþ÷åíèå íå ëîâèòñÿ
throw new Exception(" exception into finally");
//return value;
}finally{
try{
System.out.println(" finally try: begin");
return value+1;
}catch(Exception ex_finally){
System.out.println(" finally catch:");
return value+2;
}
}
//return 0;
}
/** Creates a new instance of Main */
public Main() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int value=5;
System.out.println("main:value begin="+value);
System.out.println("main:value end="+get_value(value));
System.out.println("main:---");
System.out.println("main:value begin="+value);
try{
System.out.println("main:value end="+get_value_2(value));
}catch(Exception ex){
System.out.println("main: Exception:"+ex.getMessage());
}
}
}