首页 > 其他 > 详细

异常注意事项

时间:2017-06-27 19:15:22      阅读:239      评论:0      收藏:0      [点我收藏+]
  • try   catch  finally return
  • public  int  f(){
        try{
            String demo=null;
            demo.split("a");
            System.out.println("try");                
        }catch(Exception e){        
            System.out.println("catch");               
        }finally{    
            System.out.println("finally");               
        }
    }  
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            haha a=new haha();
            a.f();
        }
    }

     

  • catch 不能独立于 try 存在。
  • 在 try/catch 后面添加 finally 块并非强制性要求的。
  • try 代码后不能既没 catch 块也没 finally 块。
  • try, catch, finally 块之间不能添加任何代码

异常注意事项

原文:http://www.cnblogs.com/-strong/p/7086524.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!