forked from singgel/java-base
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFinallyDemo.java
More file actions
43 lines (38 loc) · 944 Bytes
/
FinallyDemo.java
File metadata and controls
43 lines (38 loc) · 944 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
41
42
43
package com.hks;
public class FinallyDemo {
public static void main(String[] args){
System.out.println(m_1());
System.out.println(m_2());
}
public static int m_1(){
int i = 10;
try{
System.out.println("start");
return i += 10;
}catch(Exception e){
System.out.println("error:"+e);
}finally{
if(i>10){
System.out.println(i);
}
System.out.println("finally");
return 50;
}
}
public static int m_2(){
int i = 10;
try{
System.out.println("start");
return i += 10;
}catch(Exception e){
System.out.println("error:"+e);
}finally{
if(i>10){
System.out.println(i);
}
System.out.println("finally");
i = 50;
}
return i;
}
}