When we want to initialize data at class loading time.if we want initialize data before constructor call and when object is created then we go with init block(anonymous block).its execute with respect to every constructor whether constructor is paramterized or non parameterized.
{
Java Statements
}
After variable declaration you can write init block anywhere in the program. Don’t keep init block in method otherwise it’s treated as normal statement. We can have more than 1 init block in case of more than 1 init block in a program, their order of execution is determine by their order of entries in a class in FCFS Manner. And don’t create an object of a class inside init block in the class where we define init block. You can create object of another class.
When we compile our program with init blocks, then at compile time compiler add it into the top of the line in every constructor in a program. Whether constructor is parameterized or non parameterized.