This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan 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