标签:private package public super return
package JVM;
class Singleton {
public static Singleton singleton = new Singleton();
public static int a;
public static int b = 0;
private Singleton(){
super();
a++;
b++;
}
public static Singleton getInstance(){
return singleton;
}
}
public class TestSingleton{
public static void main(String[] args) {
Singleton s = Singleton.getInstance();
System.out.println(s.a);
System.out.println(s.b);
}
}
程序输出:
1
0
标签:private package public super return
原文地址:http://javazyx.blog.51cto.com/1635362/1562765