Just wondering about the reason of compiling code like this:
class MyClass extends AnotherClass {
{
MySecondClass object = new MySecondClass();
obj
The code inside the braces with no names will be part of the constructor of the class and be executed before the logic contained in the class constructor.
Quick example:
public class Foo {
{
System.out.println("Before Foo()");
}
public Foo() {
System.out.println("Inside Foo()");
}
{
System.out.println("Not After Foo()");
}
}