exception和finally里的return

遇到的一道面试笔试题,输出程序运行后的打印结果:

    class ReturnAndFinally{
        static String fun(){
            try {
                int v = 1/0;
            }catch (Exception ex){
                return "ERROR";
            }finally {
                return "OK";
            }
        }
        public static void main(String[] args) {
            String s = fun();
            System.out.println(s);
        }
    }

打印后的结果为:OK

原文地址:https://www.cnblogs.com/junlu/p/14222772.html