[Building Sakai] JLDAP connection

Charles Severance csev at umich.edu
Mon Feb 25 12:16:23 PST 2013


On Feb 25, 2013, at 11:57 AM, Alexandre Ballesté wrote:

> It seems like I asked a first course java programming question. :) shame on me. For a long time I believed that 'return' was the absolutly last statement executed in a function.
> 
> Thanks Sam for the answer. 

Alex,

Don't feel bad - I learned something I did not know from you and Sam today :)

Of course finally makes a lot of sense when Sam describes it below - but it would have been my guess that return would not run the finally block...

Because of when I learned programming, my mental model of how computers is based on FORTRAN-77 - and FORTRAN-77 does not have a finally block so that is my excuse for being confused.

Now that I know the full power of finally, now I can write some pretty obtuse but correct code...

/Chuck

> Sam Ottenhoff <ottenhoff at longsight.com> wrote:

> The finally block always executes when the try block exits. This ensures that the finally block is executed even if an unexpected exception occurs. But finally is useful for more than just exception handling — it allows the programmer to avoid having cleanup code accidentally bypassed by a return, continue, or break. Putting cleanup code in a finally block is always a good practice, even when no exceptions are anticipated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20130225/d46e8763/attachment.html 


More information about the sakai-dev mailing list