How do I use the double brace initialization?
Category: fundamental, viewed: 544 time(s).
The double brace initialization {{ ... }} is another way for initializing a collection objects in Java. It is offer a simple syntax for initializing a collection object.
What's actually happened is: the first brace creates an anonymous inner class and the second brace is an initializer block. Due to the need for creating an inner class the use of double brace initialization is considered to be slower.
Because of this performance issue you it's better not to use this technique for you production code, but using it in your unit testing can make your test looks simpler.
Download Hundreds of Complimentary Industry Resources
Get hundreds of popular Industry magazines, white papers, webinars, podcasts, and more;
all available at no cost to you. With more than 600 complimentary offers, you'll find
plenty of titles to suit your professional interests and needs.
Click Here and Sign up today!


