码迷,mamicode.com
首页 > 其他好文 > 详细

finally语句是否一定执行

时间:2019-11-03 21:52:51      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:cat   sys   string   ati   int   system   nal   ring   rgs   

package we;

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语句是否一定执行

标签:cat   sys   string   ati   int   system   nal   ring   rgs   

原文地址:https://www.cnblogs.com/yyl141/p/11789323.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!