单例设计demo
class Single {
private static Single instance = new Single();
private Single() {
}
public static Single getInstance() {
return instance;
}
public void print() {
System.out.println("This is a singleDemo test");
}
}
public class SingletonDemo {
/**
* <p> 单例设计</p>
* <p>使用 "类名.方法名" 调用静态方法</p>
* @created on 2012-4-24
*/
public static void main(String args[]) {
Single s = null;
s = Single.getInstance();
s.print();
}
}
>>
It is really my honor to share my experience together,and welcome to discuss problems with me.
posted on 2012-05-10 19:20 Alfred__Lee 阅读(304) 评论(0) 收藏 举报
浙公网安备 33010602011771号