this 就是对象本身
return this; 就是返回对象自己罗去掉这句要保存, 没有返回值.

解决方案 »

  1.   

    是我打错了 我是说能变成这样吗
    MYRec(int x1, int x2) {this.x1=x1
    this.x2=x2
    }
      

  2.   


    还有就是返回对象自己罗 是什么意思啊能不能简单点
    因为我刚学JAVA
      

  3.   

    我是说能变成这样注意
    MYRec(int x1, int x2) {this.x1=x1
    this.x2=x2
    }
      

  4.   

    1.return this 就是返回当前对象,但是你程序这么写是不可以的,this所在的函数都写到哪里了
    2.MYRec(int x1, int x2) {
        this.x1=x1;
        this.x2=x2;
      }
    如果在类定义内即为构造函数,如果在类定义外会提示没有返回型另:写程序每个语句结束要加上分号,养成良好习惯
      

  5.   

    return this -----返回当前对象;
    MYRec(int x1, int x2) {
        this.x1=x1;
        this.x2=x2;
      }
    特指MYRec类的成员MYRec.x1和MYRec.x2被初始化为参数x1和x2.
      

  6.   

    可以

    MYRect b(int x1, int x2) {
    this.x1=x1;
    this.x2=x2;
    return this;
    }

    MYRec(int x1, int x2) {
    this.x1=x1;
    this.x2=x2;
    }
    是不一样的函数了,前一个是普通的函数,返回一个MYRect对象。
    而后面的是构造函数,是不可以有返回值的,创建新的MYRect对象用。
      

  7.   

    MYRect b(int x1, int x2) 
    {
    this.x1=x1;
    this.x2=x2;
    return this;
    }
    这是一个普通成员函数,函数名为b,参数为int x1,int x2,返回值为MYRect类型,
    所以一定要返回(return),最后一句不能少!你可以用//注释掉那一行,看编译结果........
      

  8.   

    MYRect b(int x1, int x2) 是MYRect类中的一个类型为MYRect的函数 它必须要有返回值 
    return this 就是把自己本身返回给b这个函数
      

  9.   

    MYRec(int x1, int x2) {this.x1=x1
    this.x2=x2
    }
    这样应该是可以的吧
    不过变成了构造函数
      

  10.   

    晕!可以:
    MYRec(int x1, int x2) {
    this.x1=x1;
    this.x2=x2;
    }
      

  11.   

    return this 就是返回当前的对象。