【发布时间】:2015-04-07 19:23:41
【问题描述】:
我有两个例外:
class MyException1 extends Exception {
--
}
class MyException2 extends MyException1 {
--
}
function invokeValidation() throws MyException2 {
obj1.method() // it throws MyException1
obj2.method() // it throws MyException2
}
上面的代码说unhandled exception type MyException1,
即使MyException2 扩展了MyException1。为什么它在 throws 语句中期望 MyException1?
【问题讨论】:
标签: java exception-handling throws checked-exceptions