首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

JAVA菜鸟错误有关问题

2012-03-07 
JAVA初学者异常问题publicclassEmployee{publicstaticvoidmain(String[]args){try{fangfa()}catch(ArrayI

JAVA初学者异常问题
public   class   Employee{
      public   static   void   main(String[]   args)     {
             
              try
              {
                      fangfa();
              }
             
              catch(ArrayIndexOutOfBoundsException   e)
              {
                      System.out.println( "ArrayIndexOutOfBoundsException抓到异常! ");
                      throw   e;
              }
             
              catch(Exception   a)
              {
                      System.out.println( "Excetption抓到异常了! ");
              }

      }
      public   static   void   fangfa()   throws   ArrayIndexOutOfBoundsException
      {
              throw   new   ArrayIndexOutOfBoundsException();
      }
}


这些代码咋运行出错了?   谁告诉我一下。谢谢!


[解决办法]
如果你想捕捉throw e 处的异常,需再写一份try catch块

热点排行