Returning from a finally block in Java

前端 未结 6 2025
醉梦人生
醉梦人生 2020-11-22 11:02

I was surprised recently to find that it\'s possible to have a return statement in a finally block in Java.

It seems like lots of people think it\'s a bad thing to d

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 11:44

    The examples you provided are reason enough to not use flow-control from finally.

    Even if there's a contrived example where it's "better," consider the developer who has to maintain your code later and who might not be aware of the subtleties. That poor developer might even be you....

提交回复
热议问题