posted 13 years ago
From Kathy Sierra book.
A finally block encloses code that is always executed at some point after the try block, whether an exception was thrown or not.
Even if there is a return statement in the try block, the finally block executes right after the return statement is encountered, and before the return executes!
Based on the code sample provided, I think the behaviour is right.
Hit if(i==2) -> throw exception, handle exception print "2" and return, but just before returning, execute finally -> print 3.
Hope this clarifies.