class Singleton{
private static Singleton instance=new Singleton();
public static int count;
public static int count1=0;
private Singleton(){
count++;
count1++;
}
public static Singleton getInstance(){
return instance;
}
}
public class SingleTonDemo {
public static void main(String[] args) {
Singleton instance=Singleton.getInstance();
System.out.println(instance.count); //1
System.out.println(instance.count1);//0
}
慕运维8079593
相关分类