Here: first aMethod is calling then its throwing exception which is ultimately caught by finally block and printing "finally" now controll comes back to main try block which found that calling (aMethod()) has thrown exception so it caught and print "exception" and last statement as usual print.
In addition, finally is where code goes that must be done no matter what happens. It is a guarantee. Since there is no catch block, finally must do whatever it is supposed to before the method ends. When finally completes the method throws the exception back to main which in turn catches it. [ October 11, 2007: Message edited by: Steinar Steinnes ]
I'm not nitpicking but finally doesn't catch anything at all. It simply is gauranteed to execute regardless of whether an exception was thrown or not.
Flow is: aMethod is called, and throws an exception. This exception is not caught in the aMethod. finally is executed, as it is guaranteed to before the exception is thrown on. "finally" The main method catches the exception in its catch block, and deals with it. "exception" The main method continues processing until it has completed. "finished" [ October 11, 2007: Message edited by: Craig Bayley ]