当前位置: 代码迷 >> Java相关 >> 一道Java笔试题
  详细解决方案

一道Java笔试题

热度:89   发布时间:2010-11-15 01:09:16.0
package Test2;

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
----------------解决方案--------------------------------------------------------
我运行了一下,。出现好多重命名,。怎么回事?
----------------解决方案--------------------------------------------------------
不知道为什么
----------------解决方案--------------------------------------------------------