Java Reference
In-Depth Information
When the
TRy
block executes its return, the
finally
block is entered with
the "reason" of returning the value 1. However, inside the
finally
block
the value 2 is returned, so the initial intention is forgotten. In fact, if any
of the other code in the
try
block had thrown an exception, the result
would still be to return 2. If the
finally
block did not return a value but
simply fell out the bottom, the "return the value 1" reason would be re-
membered and carried out.