1、不能在finally块中执行return,continue等语句,否则会把异常“吃掉”;
2、在try,catch中如果有return语句,则在执行return之前先执行finally块
请大家下面的例子:
public class trytest {
public static void main(string[] args) {
try {
system.out.println(trytest.test());// 返回结果为true其没有任何异常
} catch (exception e) {
system.out.println("exception from main");
e.printstacktrace();
}
dothing
闽公网安备 35060202000074号