I tried writing a program to throw a Error object explicitly and written try catch block to handle the Error. It is working !!!
Even when I try throwing a Throwable object also it works just fine.
Can anyone tell me why we are allowed to write Throwable or Error in catch block while writing Exception alone would be more relevant :-)
Console output:
java.lang.Error
at ErrorCheckTry.testingthrowError(ErrorCheckTry.java:3)
at ErrorCheckTry.main(ErrorCheckTry.java:8)
Error caught in catch block
Note: I tried adding a recursive call of the testingthrowError() method above. Program terminated throwing StackOverflowError. The catch block does't work here !!!
[Added code tags - see UseCodeTags]