异常处理中的一点困惑,请指点!
本帖最后由 apollo_liiu 于 2013-01-23 17:08:11 编辑 首先看一个方法:
public static void methoda()throws Exception {
try {
int b = 12;
int c;
for(int i=2;i>=-2;i--){
c = b/i;
System.out.println("i=" + i);
}
} catch (Exception e) {
System.out.println("catch ... ");
throw new IOException();
}finally{
System.out.println("finally ... ");
}
}
public static boolean methodb() {
boolean ret = true;
try {
int b = 12;
int c;
for(int i=2;i>=-2;i--){
c = b/i;
System.out.println("i=" + i);
}
return true;
} catch (Exception e) {
System.out.println("catch ...");
ret = false;
throw new IOException();
}finally{
System.out.println("finally ...");
return ret;
}
}
finally{
System.out.println("finally ...");
return ret;
}