On Sat, Jun 5, 2010 at 12:42, Reinier Zwitserloot <[email protected]> wrote:
> Thanks for a very interesting post, Ben.
>
> You did make one gigantic mistake though - your original java remarks
> are completely wrong. Your snippet won't compile at all, and it'll
> never print "012" no matter how you look at it.
>
> You can't make the 'i' in:
>
> for (int i = 0; i < 10; i++) { ... }
>
> final. You could if you don't actually change i anywhere (INCLUDING
> removing the 'i++'), but doing that would be completely pointless.

You're quite correct, I've gotten to used to

for (final Object a: array_of_Object), where this works. I would have
had to introduce a (final) temporary variable at the top of the loop
to make my example work.

for (int i = 0; i < 10; i++) {
    final int temp = i;
    ... new Runnable() { ... temp ... };

// ben

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to