When I was working on my thesis for graduate school I spent months reading all that I could on optimizations that Java coders could consciously utilize while coding. While that was as exciting as it sounds*, I did manage to stumble across a few Java idioms that I’m surprised I don’t see used more often. One of my favorite idioms that I still use from time to time is called Double Brace Initialization. It’s a simple way to initialize collections, and I personally feel that it makes code more readable.
The first brace creates an anonymous inner class, and the second brace creates an initializer block that is executed when the anonymous class is created.
This entry was posted
on Friday, July 18th, 2008 at 2:10 pm and is filed under Programming.
You can follow any responses to this entry through the RSS 2.0 feed.
Responses are currently closed, but you can trackback from your own site.