This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
How does the code enter the finally block after the try block. I know that either a finally or a catch block executes after a try block. But how does the compiler know it , i mean wouldnt it be better to enter the catch block after the try block and then in the end execute the finally block ?
remember one thing : finally block is always executable block regardless of exception.
here you Main method calls thrower method in which exceptions are thrown in all cases. but your thrower doesnt have catch block so obviuosly it travel through the finally block and the exception are caught by main method which has catch block.
to understand, introduce a catch block in your thrower method