//问题1
class SS
{
//private Singleton
///obj = new Singleton();
public int counter1;
public int counter2 = 0;
public SS() {
counter1++;
counter2++;
}
/*public static Singleton getInstance()
{
return obj;
} */
public static void main(){
SS obj = new SS();
System.out.println(obj.counter1);
System.out.println(obj.counter2);
}
}
// main()未定义数组
//反编译命令是C:>javap -c -classpath . Singleton
//请高手留贴说明为什么运行不了
//问题2
public class AA{
public static void main(String args[]){
CC cc=new CC();
System.out.println(cc.toString());
}
}
class BB{StringBuffer output=new StringBuffer("?);
public String toString(){
return output;
}
}
class CC extends BB{
public String toString(){
return super.toString();
}
}
//toString()不能把StringBuffer()类型转换为Stirng?
评论