代码:
public class ExceptionTest5
{
public void method()
{
try
{
System.out.println("进入到try块");
System.exit(0);//这样调用的时候那么程序退出虚拟机了,所以finally里面的语句也不会执行
return;//这样调用finally里面的语句还是会执行的,最后才会return;
}
catch(Exception ex)
{
System.out.println("异常发生了");
}
finally
{
System.out.println("进入到finally块");
}
System.out.println("异常处理后续的代码");
}
public static void main(String[] args)
{
ExceptionTest5 test = new ExceptionTest5();
test.method();
}
}