异常处理finally语句

 1 package bao1;
 2 
 3 public class Text1
 4 {
 5 
 6     public static void main(String[] args)
 7     {
 8         try
 9         {
10             int a=10,b=0;
11             int c=a/b;
12         }    
13             
14         catch(Exception ex)
15         {
16             System.out.println("出现异常");
17         }
18             
19         finally//出现异常时也会被执行
20         {
21             System.out.println("这段代码我希望一定要被执行");
22         }
23     }
24 }

 

posted @ 2016-05-28 22:10  明天会更好!!!!  阅读(128)  评论(0)    收藏  举报