Prev Next

Java / Abstract Class

What is Double Brace initialization in Java?

Double brace initialization creates an anonymous class derived from the specified class and provides an initializer block.

new ArrayList<String>() {{
   add("ONE");
   add("TWO");
}};

The outer brace creates the anonymous inner class while the inner represents the initializer block.

More Related questions...

Show more question and Answers...


Comments & Discussions