求救 下面的 this()是什么意思啊 ?class TT{ 
public TT(String s){ 
this(); 
System.out.println(s); 


public class Test extends TT{ 
public static void main(String args[]){ 
Test t = new Test("This"); 

public Test(String s){ 
super(s); 

解决方案 »

  1.   


    第一,我还是不是很懂;
    第二,这样运行会提示this()这里有错啊
      

  2.   

    这里的this()是指调用本类的无参构造函数,即TT()但你这里没有提供TT类的无参构造函数,所以编译应该通不过把TT改成这样然后运行Test,可能你能更好理解this()干了啥:
    class TT {

    public TT() {
    System.out.println("hi, i am TT()!");
    }

    public TT(String s) {
    this();
    System.out.println(s);
    }
    }
      

  3.   

    楼上正解,下面的super你都能理解,这里的this为什么不能理解呢
      

  4.   


    要不你给我说说super,其实我也不是太懂,我就知道是调用父类的构造方法
      

  5.   

    1.类默认有自己的无参数构造函数,但如果在定义带参数构造函数时,会覆盖原有无参数构造函数。
    2.如果一个类同时提供无参数构造函数和带参数构造函数,需明确定义才行。
    3.this()调用本类的无参数构造函数,生成一个本类实例。
    上述代码应改为:
    class TT
    {
    //无参数构造函数
    public TT(){}
    //带参数构造函数
    public TT(String s)
    {
      this();
    }
    }