finally语句块相关面试题

    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

posted @ 2024-02-18 12:30  捞月亮的小北  阅读(9)  评论(0编辑  收藏  举报