cmbhatt
cmbhatt
So, you mean to say that if we put "throw e1;" in a try catch block the program should compile?
I tried that -- but I got the same error -- Statement unreachable.
cmbhatt
JebaRaj.<br /> MCP, SCJP 1.5 <br />----------------------------<br /> THOUGH TIMES TEACH TRUST. <br />----------------------------
cmbhatt
Originally posted by Chandra Bhatt:
Hi Guptajee,
catching the exception and declaring it is different. if main declares that it throws particular exception, you need not to place the code in the try catch block that throws the exception; because main declares that it throws it. Your first statement goes wrong "main must catch every exception".
You have only two options anywhere:
1- catch it using try catch block ofcourse.
2- declare it in the method that is throws the exception so that that need not to place the code in the try catch block; this phenomenon is called ducking;
Thanks and Regards,
cmbhatt
Similar, is the situation with the original code..main() declares that it'll throw MyException. and it does throw MyException e1 in finally block.
Then, why was there a need to put throw in try-catch for the code to compile properly
cmbhatt
I hired a bunch of ninjas. The fridge is empty, but I can't find them to tell them the mission.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|