异常例2

来源:互联网 发布:遇到网络诈骗怎么半 编辑:程序博客网 时间:2024/05/16 06:37
 public class Abnormality2  {   static void show() throws NullPointerExcepting   {  try {throw new NullPointerExcepting("demo");      //抛出一个异常    }  catch(NullPointerExcepting e)     {    System.out.print("捕捉内部异常") ;    //捕捉异常    throw e ;                          //抛出另一个异常     }   }   public static void main(String args[])   {  try{  try {show();} catch (NullPointerExcepting e) {// TODO Auto-generated catch blocke.printStackTrace();}     }  catch(NullPointerException e)  {  System.out.print("再次捕捉异常:+e") ;      //再次捕捉异常  }   }   }

0 0
原创粉丝点击