SCJP 5.0 and now fighting with ExtJS
SCJP 6
Why to worry about things in which we dont have control, Why to worry about things in which we have control ! !
If a finally block is present, it is reachable iff the try statement is reachable
SCJP 5.0 and now fighting with ExtJS
Balagopal Kannampallil wrote:It won't go back and execute the catch blocks' return statement. If try, catch and finally has return statements then the return statement of the finally block will be executed.
All code in my posts, unless a source is explicitly mentioned, is my own.
SCJP 5.0 and now fighting with ExtJS
Balagopal Kannampallil wrote:After entering the finally block, the code inside the finally block get executed and if the finally block does not have a return statement then it will execute the return statement of whatever condition it satisfied before it entered the finally block (either try or catch).
All code in my posts, unless a source is explicitly mentioned, is my own.
SCJP 5.0 and now fighting with ExtJS
Balagopal Kannampallil wrote:If the try is having a return statement and the corresponding catch and finally does not have a return statement then the method must have a default return statement at the end outside these try-catch-finally blocks (if the return type of the method is not void).
So when an excepion occurs before the return statement in the try block,the exception is caught and handled by the catch block, then the code inside the finally block gets executed and at last the default return at the end of the method will get executed and this value is retuned.
All code in my posts, unless a source is explicitly mentioned, is my own.
Banu Chowdary wrote:Hi gupta you are asking about this situation :
All code in my posts, unless a source is explicitly mentioned, is my own.
Balagopal Kannampallil wrote:If the try is having a return statement and the corresponding catch and finally does not have a return statement then the method must have a default return statement at the end outside these try-catch-finally blocks (if the return type of the method is not void).
So when an excepion occurs before the return statement in the try block,the exception is caught and handled by the catch block, then the code inside the finally block gets executed and at last the default return at the end of the method will get executed and this value is retuned.
SCJP 5.0 and now fighting with ExtJS
All code in my posts, unless a source is explicitly mentioned, is my own.
Banu Chowdary wrote:
But why the following is giving Error ???
This is also giving Error. what is the logic in this??? If there is a return only in finally it is giving error. if there is return in only catch it is giving error. But if there is return only in try it is not giving error. Why. Really I am in Confusion. I got this doubt earlier but didn't post it here.
All code in my posts, unless a source is explicitly mentioned, is my own.