Why use Finally in Try … Catch

前端 未结 14 2011
鱼传尺愫
鱼传尺愫 2020-12-05 06:38

I see that the Finally in Try .. Catch will always execute after any parts of the execution of the try catch block.

Is it any different to

14条回答
  •  臣服心动
    2020-12-05 06:47

    On top of what everyone else said, semantically I think that they are different.

    Code in the finally block clearly states that you're doing finalization type tasks for the content contained within the try-catch. I think this makes it clearer to read.

提交回复
热议问题