Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
IN the above code the FileNotFound exception is found and handeled by the catch method and thus the msg is printed. Then before the return statement the finally block gets excuted and then the return statement..
I hope it is clear now.......
That is if a return statment is embedded in the code inside the try or catch block, the code in the finally clause excuets before the return.
Hi rex tony , When the control comes to the main method , the control will go to the amethod method, now if there is any exception raised in the try block ,it looks for appropriate catch block(FileNotFoundException), if found it will execute. Here in your code ,in catch block as you are returning (return 2; //statement) integer 2,before it returns the value it will search for the finally block to execute. I hope you understood. give your valuable feedback.