a.在try语句之前就return了

  b.try语句中有System.exit();语句

二:finally语句在return执行之后,return返回之前执行

  例1:

public class FinallyTest1 {
    public static void main(String[] args) {
        test1();
    }
    public static int test1(){
        int b=20;
        try {
            System.out.println("try block");
            return b += 80;
        }
        catch (Exception e) {
            System.out.println("catch block");
        }
        finally {
            System.out.println("finally block");
            if (b > 25) {
                System.out.println("b>25, b = " + b);
            }
        }
        return b;
    }
}

console:

try block
finally block
b>25, b = 100
View Code

相关文章: