public class Exceptiontest
{
public static void main(String[] args) throws Exception
{
try{
System.out.println("zai try中");
}catch(Exception e){
System.out.println("zai catch中");
throw new Exception("在catch中的throw");
}finally{
System.out.println("zai finally");
}
}
}
执行结果是:
zai try中
zai finally
说明:尽管在catch中使用throw,程序依然会执行finally中的语句
本文探讨了Java中异常处理机制中的try-catch-finally结构,重点解释了在catch块中使用throw关键字后,程序仍然执行finally块中的语句。通过实例演示,深入理解Java异常处理流程。
1513

被折叠的 条评论
为什么被折叠?



