码迷,mamicode.com
首页 > 编程语言 > 详细

Java自定义异常

时间:2015-04-29 21:23:44      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:

 class OwnException extends Exception {
      public OwnException(String msg) {              
            super(msg);
            System.out.println("hello myexception");
        }

}
class OwnExceptionSource {
      public void a() throws OwnException{
             throw new OwnException(null);
         }

}
public class OwnExceptionHandler1{
    public static void main(String[] args) {
         OwnExceptionSource r = new OwnExceptionSource();
            try{
                r.a();
                //System.out.println("in try block");
            }catch(Exception e) {
                //System.out.println("in catch block");
                e.printStackTrace();
            }finally{
                System.out.println("the last");
            }
            //System.out.println("after exception");
        }    
}

 

Java自定义异常

标签:

原文地址:http://www.cnblogs.com/xuhuaiqu/p/4466961.html

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