一道Java笔试题
public class Sigleton {private static Sigleton sigleton=new Sigleton();
private static int count1;
private static int count2=0;
public Sigleton(){
count1++;
count2++;
}
public static Sigleton getInstance(){
return sigleton;
}
public static void main(String[] args) {
Sigleton t=Sigleton.getInstance();
System.out.println(t.count1);
System.out.println(t.count2);
}
}
写出程序的输出结果
[ 本帖最后由 西鄙人 于 2010-11-5 09:27 编辑 ]