例波纹管的程序,凡在try块defectedCode()方法被调用,那么为什么只有输出只显示C,带有“Exception in thread”主“java.lang.Error”。时抛出新的错误()被写在try块,为什么不执行catch块。它进入最后只能.Latter代码也不会执行
public class ExceptionTest {
public static void defectedCode(){
throw new Error();
}
public static void main(String args[]){
try{
defectedCode();
System.out.println("A");
}catch(Exception e){
System.out.println("B");
}finally{
System.out.println("C");
}
System.out.print("D");
}
}
Exception in thread "main" java.lang.Error
C
at ExceptionTest.defectedCode(ExceptionTest.java:15)
at ExceptionTest.main(ExceptionTest.java:21)
Java Result: 1