运行
package demo; public class Demo2 { 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"); } } }
结果
in main Exception is thrown in main
在catch中,结束程序,finally将不被执行
标签:语句,Exception,动脑,System,finally,println,main,out From: https://www.cnblogs.com/ashuai123/p/16822197.html