“常用公式”在线计算,“设计手册”在线查询
1> try catchblock and2> specifying the candidate exceptions in thethrows clause?When should you use which approach?
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享 分享淘帖 支持支持 反对反对

共 1 个关于本帖的回复 最后回复于 2013-8-16 16:15

沙发
胡一搏 新来的 发表于 2013-8-16 16:15:15 | 只看该作者
研发埠培训中心
In the first approach as a programmer ofthe method, you urself are dealing with the exception. This is fine if you arein a best position to decide should be done in case of an exception. Whereas ifit is not the responsibility of the method to deal with it's own exceptions,then do not use this approach. In this case use the second approach. In thesecond approach we are forcing the caller of the method to catch theexceptions, that the method is likely to throw. This is often the approachlibrary creators use. They list the exception in the throws clause and we mustcatch them. You will find the same approach throughout the java libraries weuse.
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注我们

360网站安全检测平台