This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori 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