What are static blocks and static initializers in Java?

Static blocks or static initializers are used to initialize static fields in java.

We declare static blocks when we want to initialize static fields in our class.

Static blocks gets executed exactly once when the class is loaded.

Static blocks are executed even before the constructors are executed


Posted

in

Tags:

Comments

Leave a Reply