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.