try finlly return

public class Test {
    public static void main(String[] args) {
        System.out.println();
            System.out.println(new Test().test()); //1
     }
    static int test() {
        int x= 1;
        try  {
            return x;
        } finally {
            ++x;
            System.out.println(x);
        }
    }
}

 

http://blog.sina.com.cn/s/blog_69d4185b010197h8.html

posted @ 2019-07-11 16:44  三十六烦恼风x  阅读(149)  评论(0编辑  收藏  举报