【发布时间】:2014-11-27 08:03:09
【问题描述】:
我真的不明白 finally 块的使用... 在 try-catch 块中,无论我们是否使用 finally,我们都可以获得相同的代码运行。 例如这些代码有什么区别:
try
{
System.out.println(1/0);
}
catch(ArithmeticException e)
{
System.out.println("Error");
}
finally
{
System.out.println("After try-catch");
}
还有这个:
try
{
System.out.println(1/0);
}
catch(ArithmeticException e)
{
System.out.println("Error");
}
System.out.println("After try-catch");
运行代码的输出或层次结构在逻辑上有何不同???
【问题讨论】:
标签: exception-handling try-catch finally