Top News

In what scenario do we use a static block?

 


At times, there is a class that has static member variables. These variables need some complicated initialization. At this time static block helps as a tool to initialize complex static member variable initialization.

 The static block is executed even before the execution of main. Sometimes, we can also replace static block with a static method of class.


Post a Comment

Previous Post Next Post