Java try-finally return design question

后端 未结 7 2343
滥情空心
滥情空心 2020-11-27 04:04

In Java, a try { ... } finally { ... } is executed somewhat unintuitively to me. As illustrated in another question, Does finally always execute in Java?, if you have a retu

7条回答
  •  暖寄归人
    2020-11-27 04:25

    If code in finally block ends abruptly, it changes return value/exception from try block. This is considered to be bad practice, and you should not do that.

    Among other places, this is also discussed in Java Puzzlers book.

提交回复
热议问题