posted 18 years ago
Hi V Bose,
Thats because Throwable includes Runtime and Checked exceptions both. If you look at API it will tell that,
Throwable is parent of Exception,Error and in Error API it says,
A method is not required to declare in its throws clause any subclasses of Error that might be thrown during the execution of the method but not caught, since these errors are abnormal conditions that should never occur.
which means the code in try catch can throw Error even w/o making methods called in that block as "throws Error" you know.
So, when we write catch Throwable it assumes that we want to probably catch some Error which occurs at runtime. If you write Exception then it means it could be checked exception and in that case it goes and see if there is a possibility of getting any checked exception in the code or not. Hence it doesn't compile if there is no possbility of getting checked exception in the try catch block.
Hope it helps.
Maulin