Why private static field = new Singleton is not lazy in Java?

后端 未结 3 959
一个人的身影
一个人的身影 2021-01-18 12:45

I read a lot of articles about Singleton, in most of which authors said that this variation of Singleton in Java:

public class Singleton {
    private static         


        
3条回答
  •  耶瑟儿~
    2021-01-18 13:01

    It is not lazy because the singeton object is created once the class is loaded.
    A lazy Singleton would create the object when it is first used.

提交回复
热议问题