What is the point of the finally block?

后端 未结 16 1218
长情又很酷
长情又很酷 2020-12-30 20:19

Syntax aside, what is the difference between

try {
}
catch() {
}
finally {
    x = 3;
}

and

try {
}
catch() {
}

x = 3;
         


        
16条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-30 21:00

    The finally block is supposed to execute whether you caught the exception or not. See Try / Catch / Finally example

提交回复
热议问题