I know Java supports the object initialization blocks as shown below. The following code shows that the object initialize block always calls when the TestObjectInitialize instance has been created.
public class TestObjectInitialize {
public int abc;
//object initialize block
{
abc= 5;
}
public TestObjectInitialize() {
}
public static void main(String... args) {
TestObjectInitialize toi = new TestObjectInitialize();
System.out.println(toi.abc);
}
}
I have seen people do this:
It can be useful when you have a method
You can call it like this: