[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bindings and assignments
Michael Vanier <firstname.lastname@example.org> writes:
>> Date: Thu, 14 Aug 2003 10:45:34 -0400
>> From: "David B. Tucker" <email@example.com>
>> Out of curiosity, does anyone know why Java only allows final variables
>> to be referenced from within anonymous classes?
> This is my #1 pet peeve about java. It drives me crazy.
This is #2 for me, right behind "primitives are not objects", which
makes Java collections a world of pain. But as with so many things in
Java, it doesn't make things impossible so much as awkward, painful,
and inefficient. The "solution" I've settled on to both of these
problems is to use 1-element arrays. A final 1-element array doesn't
have final elements, and a 1-element primitive array is an object.
As an added bonus, you get to avoid doing two accesses to update a