public class ExceptionDemo4 {
/**
* @param args
*/
public static void main(String[] args) throws ArithmeticException {
// TODO Auto-generated method stub
Demo d=new Demo();
d.div(4, 0);
System.out.println("asd");//为什么抛异常 不执行呢?
}
}
class Demo
{
int div(int a,int b)// throws ArithmeticException
{
if(b==0)
throw new ArithmeticException("出错了");
return a/b;
}
}
Exception in thread "main" java.lang.ArithmeticException: 出错了
at Demo.div(ExceptionDemo4.java:21)
at ExceptionDemo4.main(ExceptionDemo4.java:10)
为什么不执行System.out.println("asd");// |