When should I use the finally-block in Java's try-catch-finally

前端 未结 5 1093
北恋
北恋 2021-02-13 11:39

When should I use code snippet A instead of snippet B (i.e. what are the benefits of using snippet A)?:

Snippet A:

try {
    // codebloc         


        
5条回答
  •  臣服心动
    2021-02-13 12:24

    Imagine to have a return statement inside the catch block: the C block will not be executed in snippet B, but in snippet A it will, before returning.

提交回复
热议问题