public class SingletonDemo {
private SingletonDemo() {
// do something...
}
public static SingletonDemo getInstance() {
return SingletonHolder.instance;
}
private static class SingletonHolder {
private static final SingletonDemo instance = new SingletonDemo();
}
public void function1()....
public void function2()....
}
Design Pattern - Singleton
良葛格已分享許多方法與範例, 在此提供 Inner Class 的方法
0 意見:
張貼留言