我想以下例子; 但无法弄清楚finally块的重要性是什么.你能告诉我这两个代码示例的执行区别吗?现实生活中的例子也很有帮助.
样本1:
try{
// some code 1
}catch(Exception ex){
// print exception
}finally{
// some code 2
}
Run Code Online (Sandbox Code Playgroud)
样本2:
try{
// some code 1
}catch(Exception ex){
// print exception
}
// some code 2
Run Code Online (Sandbox Code Playgroud)