public class Sigleton {
private static Sigleton sigleton=new Sigleton();
private static int count1;
private static int count2=0;
public Sigleton(){
System.out.println("you");
count1++;
count2++;
}
public static Sigleton getInstance(){
System.out.println("fuck");
return new Sigleton();
}
public static void main(String[] args) {
Sigleton t=Sigleton.getInstance();
System.out.println(t.count1);
System.out.println(t.count2);
}
}
运行一下就知道为什么
----------------解决方案--------------------------------------------------------
1
0
----------------解决方案--------------------------------------------------------
我运行了一下,。出现好多重命名,。怎么回事?
----------------解决方案--------------------------------------------------------
不知道为什么
----------------解决方案--------------------------------------------------------