【发布时间】:2015-10-26 17:26:03
【问题描述】:
我无法理解抛出异常时会发生什么。
抛出的异常会发生什么?什么处理它以确保程序不会崩溃?
例如,在这个来自this tutorial 的示例中,如何处理抛出的ArithmeticException?
static int remainder(int dividend, int divisor)
throws DivideByZeroException {
try {
return dividend % divisor;
}
catch (ArithmeticException e) {
throw new DivideByZeroException();
}
}
【问题讨论】: