本文介绍了不能离开一个finally子句的正文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好朋友,
如果我在try catch finally块的finally子句中放入一个return语句,我会收到如下错误:
Hello friends,
If i put a return statement in a finally clause of a try catch finally block, i get an error like below:
引用:
不能离开finally子句的正文
Cannot leave the body of a finally clause
假设:
Suppose:
try
{
}
catch(SomeException e)
{
}
finally
{
return some_value;
}
有人可以解释其背后的原因吗?我删除了错误。我不知道为什么会这样?背后的原因是什么?
谢谢
Can some one please explain the reason behind it? I removed the error. Bu i am inquisitive as to why does this happen? whats the reason behind it?
Thanks
推荐答案
try
{
}
catch(SomeException e)
{
}
finally
{
//clean up code
}
return some_value;
问候
Dominic
Regards
Dominic
try
{
}
catch(SomeException e)
{
}
finally
{
}
return some_value;
这篇关于不能离开一个finally子句的正文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!