从方法返回,在“try”块中还是在“捕获”块之后?
以下两种方法有什么区别吗?
哪一个更可取,为什么?
Prg1:
public static boolean test() throws Exception {
try {
doSomething();
return true;
} catch (Exception e) {
throw new Exception("No!");
}
}
Prg2:
public static boolean test() throws Exception {
try {
doSomething();
} catch (Exception e) {
throw new Exception("No!");
}
return true;
}