结果应该是B,C,D
class Demo
{
public static void main(String[] args)
{
try
{
showExce(); //这个方法会抛出异常,这里转到下面Catch
System.out.println("A");
}
catch(Exception e)//这里捕捉到异常并处理打印B
{
System.out.println("B");
}
finally
{
System.out.println("C");//finally里面存放的是一定会执行的代码打印C,D
}
System.out.println("D");
}
public static void showExce()throws Exception
{
throw new Exception();
}
} |