Curly braces in "new" expression? (e.g. "new MyClass() { ... }")

android, class, curly-braces, java, syntax

Solution

This is the syntax for creating an instance of anonymous class that extends `Handler`. This is part of Java.

Problem

What do the curly braces do there ? ``` handler1 = new Handler() { public void handleMessage() { } }; ``` `object = new Class_Name() {};` ? This syntax exists only on Android or Java also? And what is it called in Java? Thank for your helps.

Original source

Related problems