在我准备复习的一篇论文中,有这样一个问题: "catch 块可以是多态的吗?" 如果是真的,对我来说,叫多个 catch 块多态化没有意义。如果 catch 块不能被命名,并且只在其方法头中包含参数,那它是否具有多态性呢?
例如:
在这段代码中,这两个
try {
//...
} catch (FileNotFoundException e) {
System.err.println("FileNotFoundException: " + e.getMessage());
throw new SampleException(e);
} catch (IOException e) {
System.err.println("Caught IOException: " + e.getMessage());
}
在这段代码中,这两个
catch
块是否具有多态性?