Ama*_*man 2 java exception-handling compiler-errors exception
这是代码示例,我收到错误"必须被捕获或声明被抛出",但我有
已经处理了IOException.所以你能告诉我为什么错误填充.代码也
跟随句柄并声明规则.
public void rethrow() throws SQLException, IOException {
try {
couldThrowAnException();
}
catch(Exception e) {
e = new IOException();
throw e; //Error: must be caught or declare to be thrown
}
}
Run Code Online (Sandbox Code Playgroud)