读书人

JAVA菜鸟错误有关问题

发布时间: 2012-03-07 09:13:51 作者: rapoo

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块

读书人网 >J2SE开发

热点推荐