What is Double Brace initialization syntax in Java?
+1
A:
It's - among other uses - a shortcut for initializing collections. Learn more ...
The MYYN
2009-12-24 15:08:54
Well, that's one application for it, but by no means the only one.
skaffman
2009-12-24 15:12:02
+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
2009-12-24 16:40:56
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
2009-12-24 16:56:29
@lambdageek you might also like http://www.iam.unibe.ch/~akuhn/blog/2008/roman-numerals-in-your-java/
Adrian
2009-12-26 02:54:52
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
2009-12-28 00:11:13