This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Hi Vivek The reason why you get the following is as follows. Once the code a==null is successfull, the MalformedURLException is thrown. This exception is caught in the same test() method which prints CaughtMalformedURLException and again throws the same execption. But before control is transferred to the main, finally() is executed, so it prints End finally. Then this exception is caught in the main() method which prints Exception at main(). Hope this clarifies Anand
dear vivek, note that MalformedURLexception is a checked exception. 1. this means that this exception must either be caught using the try-catch construct, or , be declared in the throws clause of the invoking method. 2. in your code, this exception is caught using the first catch construct. it is then RETHROWN. 3. since it is checked exception, it has to be declared in the throws clause of invoking method ie test(). note that this is not done. the test() method only throws one IOException. 3. thus, after execution of finally, method is aborted and hence result hth, chetan