public class Singleton {
private static Singleton s = null;
private Singleton() { }
public static Singleton getInstance() {
if (s == null) s = new Singleton();
return s;
}
public void fun() { /* some code */ }
public static void staticfun() { /* some code */ }
public static void main(String[] args) {
Singleton.getInstance().fun();
Singleton.staticfun();
}
}
------解决方案--------------------