我知道下面的代码确实有意义:
try { ... }
catch (FileNotFoundException exc) { ... }
catch (IOException exc) { ... }
但是在throws 子句中声明那些父子异常有意义吗?
假设我有以下代码:
public void doSomething() throws FileNotFoundException, IOException { ... }
我们都知道那FileNotFoundException
是IOException
. 现在以任何方式(可读性,性能等)声明它是否有意义,反对只是这样:
public void doSomething() throws IOException { ... }