A static initializer is a block of code that is used to initialize the static variables of a class. It is written as follows:
static statement-block
Static initializers can only access static class variables. They are executed in the order in which they appear in a class declaration. A statement block is a list of zero or more statements enclosed in parentheses. The parentheses are mandatory, even if there are no statements in the statement block.
Object initializers are used to initialize non-static variables of a class and are executed immediately after a class’s superclass constructor is invoked. They are written as follows:
do statement-block