【发布时间】:2013-11-22 19:54:58
【问题描述】:
鉴于 java 中的以下 try/catch 块:
try{
return;
}
catch(SomeException e){
System.out.println(e);
}
finally{
System.out.println("This is the finally block");
}
根据这篇文章:“Does finally always execute in Java?”我可以看到程序的输出将是“这是 finally 块”。但是,我无法弄清楚这是怎么可能的,因为 print 语句前面有一个 return ...
我怀疑这种行为与线程有关,但我不确定。请赐教。谢谢。
【问题讨论】:
-
该问题的第三个答案详细解释了它。
标签: java return try-catch try-catch-finally