Use and flow of Static statements in Singleton Program

后端 未结 6 591
面向向阳花
面向向阳花 2021-01-14 13:29

I know there are lot of questions on Singleton pattern. But here what I would like to know about the output which might also cover how \"static\" works in Java.



        
6条回答
  •  余生分开走
    2021-01-14 14:08

    whenever control comes to any class for the first time, all the static initializations take place first. That's why your static object is being instantiated before anything else by calling it's constructor.

提交回复
热议问题