throw
手动抛出异常
执行异常的抛出动作
private static double divide(double a, double b) {
if(b==0){
//新建异常对象
ArithmeticException e = new ArithmeticException("/ by zero 异常");
//把异常对象抛回到调用位置
throw e;
}
return a/b;
}