?
import java.io.IOException;
/**
*
*/
/**
* @author taoge
*
*/
public class TestException {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
foo(0);
foo(1);
}
public static void foo(int i){
String str="";
try {
if (i==1) {
throw new IOException();
}
str+=1;
} catch (IOException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
str+=2;
return;
}finally{
str+=3;
System.out.println("test");
}
str+=4;
System.out.println(str);
}
}
?
test 134 test
?
?
由此可见,当catch 模块遇到return 的时候,在return 之前执行 finally模块语句,然后再执行return
?
try catch 模块 catch 部分有return 语句处理
原文:http://taoge-tony.iteye.com/blog/2161647