Scenario:
class Assert {
public static void main(String []args) {
try {
assert false;
}
catch (RuntimeException re) {
System.out.println("In the handler of RuntimeException");
}
catch (Exception e) {
System.out.println("In the handler of Exception");
}
catch (Error ae) {
System.out.println("In the handler of Error");
}
catch (Throwable t) {
System.out.println("In the handler of Throwable");
}
}
}
I am expecting 'In the handler of Error' because AssertionError is subclass of Error but it doesn't show anything and terminate normal. after then to check the out put I added this one catch handler before Error handler .
catch (AssertionError t) {
System.out.println("In the handler of Throwable");
}
in know it's not a good practice to catch Error but if we does not need to catch why the program was not crashed it terminate normally?