我不必在保证抛出异常的函数中指定返回值,因为该路径已死:
// Works fine!
public boolean a() {
throw new RuntimeException();
}
我不明白为什么我不能在这里做同样的事情:
// Error: This method must return a result of type boolean
public boolean a() {
try {
return mayReturnOrThrow();
}
catch (Exception ex) {
new RuntimeException(ex);
}
}
我在这里想念什么?