I've recently noticed this construct in java that allows executing code before the constructor gets called:
public class Foo {
{
System.out.println("before constructor 1");
}
public Foo () {
System.out.println("constructor");
}
{
System.out.println("before constructor 2");
}
}
With this class, when constructor is called:
new Foo();
this gets to the output:
before constructor 1
before constructor 2
constructor
I would like to know more about this construct: how is it called, when it was added, documentation page url ...