为什么 catch 参数是隐式最终参数?
catch (IOException|SQLException ex) {
logger.log(ex);
throw ex;
}
为什么 ex
是隐式最终的?让 ex 隐式最终有什么用?
catch (IOException|SQLException ex) {
logger.log(ex);
throw ex;
}
here why is ex
implicitly final? What is the use of making ex implicitly final?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它是隐式最终的,因为更改
ex
指向的对象没有意义,特别是在它可能是IOException
或的情况下SQLException
,因此编译器很难弄清楚(静态)赋值类型。It's implicitly final because it does not make sense for you to change the object pointed to by
ex
, especially in this case where it could be either anIOException
or anSQLException
, and thus the (static) assignment typing would be difficult to figure out by the compiler.