首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

try catch finally有关问题

2012-10-15 
try catch finally问题public static int process() throws Exception {try {System.out.println(try)

try catch finally问题
public static int process() throws Exception {
try {
System.out.println("try"); //1
return 1; //2
} finally {
System.out.println("finally"); //3
}
}
执行流程,为什么?

public static int process() throws Exception {
try {
System.out.println("try"); //1
return 1; //2
} finally {
System.out.println("finally"); //3
return 3; //4
}
}
执行流程,为什么?

[解决办法]
http://www.ticmy.com/?p=56
[解决办法]
try catch finally

按顺序执行try,再执行finally,在执行try catch finally 之外代码
按顺序执行try,发生异常则执行catch 再执行finally, try catch finally以外不执行。

热点排行
Bad Request.