Design Pattern—Singleton
2014-02-19 15:59
453 查看
Singleton
Console Display:
true
true
public class textSingleton{ public static void main(String[] args) { Singleton singleton=Singleton.getInstance(); Singleton singleton2=Singleton.getInstance(); Singleton singleton3=Singleton.getInstance(); System.out.println(singleton==singleton2); System.out.println(singleton2==singleton3); } } class Singleton { private static Singleton singleton; private Singleton(){ } public static Singleton getInstance(){ if(singleton==null){ singleton=new Singleton(); } return singleton; } }
Console Display:
true
true
相关文章推荐
- Private Constructor and Singleton design pattern
- Objective c singleton design pattern
- (C#)Singleton design pattern sample
- [置顶] 设计模式之单例模式 (Design patterns of the The singleton pattern)c#
- 单态设计模式(Singleton Design Pattern)
- 设计模式之单例模式 (Design patterns of the The singleton pattern)c#
- 07/11/2014 J2EE 学习笔记 Design Pattern Observer,Singleton et Iterator
- Head First Design Pattern - 5 - This week's interview: Confessions of a Singleton
- design_pattern_singleton
- 单态设计模式(Singleton Design Pattern)
- Design Pattern Singleton 单一模式
- Learning JavaScript Design Patterns The Singleton Pattern
- Singleton Design Pattern
- 单态模式(Singleton Design Pattern)
- design_pattern_singleton
- 单件模式 (Singleton design pattern)
- design pattern notes [2] - decorator, facade, Singleton, Flyweight, and Adapter
- 单态设计模式(Singleton Design Pattern)
- 单态设计模式(Singleton Design Pattern)
- It's bad design that leveraging singleton design pattern in db connection