finally语句块相关面试题

捞月亮的小北 / 2024-02-18 / 原文

    public static void m() {
        try {
            System.out.println("try...");
            System.exit(0);
        } finally {
            System.out.println("finally...");
        }
    }

上述程序中 , finally语句块中的内容还能被执行吗?
答:不能被执行

    public static int m3(){
        int i = 100;
        try {
            return i;
        } finally {
            i++;
        }
    }

上述程序中i的值最终为多少
答:最终值为 100