Difference between try-finally and try-catch

前端 未结 11 545
栀梦
栀梦 2020-12-23 03:05

What\'s the difference between

try {
    fooBar();
} finally {
    barFoo();
}

and

try {
  fooBar();
} catch(Throwable thro         


        
11条回答
  •  离开以前
    2020-12-23 03:25

    Finally block is always executed. Catch block is executed only when an exception that matches the blocks parameter is catched.

提交回复
热议问题