News for hackers. Stuff that matters.
Re:Relax. You can (mostly) stop using Interfaces in Java now by lambdom on Monday March 08, 2010 @10:18AM (#1175469)
Is it me or in both of the examples there is an extra { ? Is this something about Java I don't know about?
Re:Relax. You can (mostly) stop using Interfaces in Java now by Robin_Message on Monday March 08, 2010 @10:29AM (#1175488)
The first { opens the body of the anonymous inner class.

The second { starts an instance initialization block, which runs on each object when it is constructed - not sure if it's before or after the constructor - gonna guess before!

It's useful in this case as anonymous inner classes can't define constructors.

Re:Relax. You can (mostly) stop using Interfaces in Java now by samuel on Monday March 08, 2010 @10:29AM (#1175487)
No, it isn't. The first { encloses the class and the second encloses the "anonymous constructor" or whatever is called. It's code executed at object creation, even before the "named" constructor.