Effectively final effective?
Peter Levart
peter.levart at gmail.com
Sun Feb 28 01:32:50 PST 2010
You meant 333 vs. 012 didn't you?
Peter
On Sunday 28 February 2010 12:37:26 am John Nilsson wrote:
> Please ignore the off my one error... imagine i wrote 222 and 012
> respectively...
>
> On Sun, Feb 28, 2010 at 12:36 AM, John Nilsson <john at milsson.nu> wrote:
> > Am I correct in interpreting the 4 sentiments listed below like so:
> >
> > Given this code
> >
> > List<()->int> funs = new ArrayList<>();
> > for(int i = 0; i < 3; i++)
> >
> > funs.add(()->i)
> >
> > for(()->i f : funs)
> >
> > System.out.print(f.());
> >
> > The following is the result
> >
> > 1. Prints: 333
> > 2. Compiler error at i++ (mutating a final variable)
> > 3. Prints: 123
> > 4. Compiler error at ()->i (trying to access a non-final var)
> >
> > BR,
> > John
More information about the lambda-dev
mailing list