标签:
package com.wyc.cn;
/**
* 单例设计模式
* @author buyi
* @date 2015-09-03
* **/
class SingLeton {
private static SingLeton singLeton ;
private SingLeton() {
}
public static SingLeton getInstance() {
if(null == singLeton) {
singLeton = new SingLeton() ;
}
return singLeton ;
}
}
public class SingLetonTest {
public static void main(String[] args) {
SingLeton singLeton = SingLeton.getInstance();
SingLeton singLeton1 = SingLeton.getInstance();
System.out.println(singLeton == singLeton1);
}
}
标签:
原文地址:http://www.cnblogs.com/wyc20131223/p/4781797.html