class test_throw
{
static void test()
{
int c;
try
{
c=2/0;
}
catch(ArithmeticException e)
{
throw e; //这里发现异常就应该处理了啊?为什么还要抛出去等其它方法处理呢?
}
} public static void main(String args[])
{
try
{
test();
}
catch(ArithmeticException e)
{
System.out.println("除数为零");
}
}
{
static void test()
{
int c;
try
{
c=2/0;
}
catch(ArithmeticException e)
{
throw e; //这里发现异常就应该处理了啊?为什么还要抛出去等其它方法处理呢?
}
} public static void main(String args[])
{
try
{
test();
}
catch(ArithmeticException e)
{
System.out.println("除数为零");
}
}
function 测试()
{
if(4>6)
throw ("傻货")
}
但你的这个程序一定是刻意为之的,因为ArithmeticException本来就是个RuntimeException,不需要catch,重新抛出就更没有必要了。