zoukankan      html  css  js  c++  java
  • finally语句用法

    辨析:finally语句块一定会执行吗?

    请通过 SystemExitAndFinally.java示例程序回答上述问题

     public class SystemExitAndFinally {

       public static void main(String[] args)

        {

           try{   

                System.out.println("in main");   

                throw new Exception("Exception is thrown in main");        

                    //System.exit(0);       

               }

      catch(Exception e) 

                 {  

                     System.out.println(e.getMessage());

                     System.exit(0); 

                 }    

             finally

            {     

              System.out.println("in finally");

            }

       }

    }

    运行结果截图:

    这时候finally语句执行。

    //System.exit(0);  改为System.exit(0);  

    运行截图:

     

    求解答:finally语句什么时候执行?

  • 相关阅读:
    总结一下vue里一些小技巧
    vue使用过程常见的一些问题
    Vue.js 的几点总结Watchers/router key/render
    Hibernate-3
    Hibernate-2
    Hibernate-1
    百词斩一面9.17
    vivo一面凉经
    中兴技术面被怼面经
    红黑树
  • 原文地址:https://www.cnblogs.com/1995-qxl/p/4964328.html
Copyright © 2011-2022 走看看