try,catch和finally中的执行顺序是什么 [英] What is the order of execution in try,catch and finally
问题描述
如果我们在尝试中给出这样的return语句,执行顺序将是
try {
--- ----
-----
返回a;
}
渔获{
}
最终{
}
如果尝试返回,这里的执行顺序是什么。请让我知道
http://docs.oracle.com/javase/tutorial/essential/exceptions/finally.html
http:// docs .oracle.com / javase / specs / jls / se7 / html / jls-14.html#jls-14.20.2
最终
始终执行。如果在尝试
中有返回
,则其余的 try
和 catch
不执行,然后最终
执行(从最里面到最外面),然后函数退出。 / p>
If we give return statement like this in try, what will be the order of execution
try{
--- ----
-----
return a;
}
catch{
}
finally{
}
Here what will be order of execution if there is return in try. Please let me know
http://docs.oracle.com/javase/tutorial/essential/exceptions/finally.html
http://docs.oracle.com/javase/specs/jls/se7/html/jls-14.html#jls-14.20.2
finally
always executes. If there is a return
in try
, the rest of try
and catch
don't execute, then finally
executes (from innermost to outermost), then the function exits.
这篇关于try,catch和finally中的执行顺序是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!