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.
In languages like C curly braces ( {} ) are used to create program blocks used in flow control. In Python, curly braces are used to define a data structure called a dictionary (a key/value mapping), while white space indentation is used to define program blocks.
In programming, curly braces (the { and } characters) are used in a variety of ways. In C/C++, they are used to signify the start and end of a series of statements. In the following expression, everything between the { and } are executed if the variable mouseDOWNinText is true. See event loop.
It's called an initializer block and is invoked every time an instance of the class is created. The Java compiler copies initializer blocks into every constructor. Therefore, this approach can be used to share a block of code between multiple constructors.
This is the syntax for creating an instance of anonymous class that extends Handler
. This is part of Java.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With