2

bang的设计模式讲解中的不理解的一个问题

 6 months ago
source link: https://www.jdon.com/14339.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

bang的设计模式讲解中的不理解的一个问题

BNAG在http://www.jdon.com/designpatterns/singleton.htm 文章中提到第二中形式的好处是“这个方法比上面有所改进,不用每次都进行生成对象,只是第一次” 单例模式中,用第一中方法的时候难道是每次都生成对象吗?静态的变量不是只初始化一次吗? 即使是静态变量等于NEW 一个类,那么类装入以后,初始化静态变量的时候,也应该只是一次把,以后即使再次调用,也不会再生成对象了把? 我的JAVA的运行是的装载和初始化不是很清楚,请指教。多谢


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK