views:

601

answers:

4

What is Double Brace initialization syntax in Java?

+1  A: 

It's - among other uses - a shortcut for initializing collections. Learn more ...

The MYYN
Well, that's one application for it, but by no means the only one.
skaffman
+6  A: 

Note that an effect of using this double brace initialisation is that you're creating anonymous inner classes. The created class has an implicit this pointer to the surrounding outer class. Whilst not normally a problem, it can cause grief in some circumstances e.g. when serialising, and it's worth being aware of this.

Brian Agnew
A: 

This would appear to be the same as the with keyword so popular in flash and vbscript. It's a method of changing what this is and nothing more.

Chuck Vose
+1  A: 
Adrian
Wow! This is cool! Thanks for sharing that link! :)
missingfaktor
@lambdageek you might also like http://www.iam.unibe.ch/~akuhn/blog/2008/roman-numerals-in-your-java/
Adrian
I love your entire blog! Added to favorites! :)
missingfaktor
Thanks for the credits. One of my new year's resolutions is to blog more often. For example, I plan a weekly column on meta-programming in Smalltalk.
Adrian