当然没有任何问题
this一般有强调背景的作用,如在一个类中
class Demo extends Applet {
  private int t;
  public void foo(int t){
     this.t = t;  // 这里this强调了左边的t是类Demo的成员t,右边的t是函数参数,通过函数调用传来
    }
 }

解决方案 »

  1.   

    没有问题,因为this是对当前对象的引用,    而你只要在当前对象的范围内,那么是可以不加this的   它默认为当前对象的成员.   我只用来在不记得它的成员函数时用this, 或者:   public class AA {
          int a;
          int b;
          public AA(int a,int b) {
             this.a = a;
             this.b = b;
          }
       }
      

  2.   

    但我经常看到书上老喜欢加this
      

  3.   

    而你只要在当前对象的范围内,那么是可以不加this的。。楼上的楼上举个栗子??
      

  4.   

    我只用来在不记得它的成员函数时用this,如何理解
      

  5.   

    书上加上THIS是一种好习惯,可以让读者看的明白些
      

  6.   

    有问题,因为this是对当前对象的引用,    而你只要在当前对象的范围内,那么是可以不加this的   它默认为当前对象的成员.   我只用来在不记得它的成员函数时用this, 或者:   public class AA {
          int a;
          int b;
          public AA(int a,int b) {
             this.a = a;
             this.b = b;
          }
       }只用来在不记得它的成员函数时用this,怎么可能不记得他的成员函数
      

  7.   

    再次up,
    有问题,因为this是对当前对象的引用,    而你只要在当前对象的范围内,那么是可以不加this的   它默认为当前对象的成员.   我只用来在不记得它的成员函数时用this, 或者:   public class AA {
          int a;
          int b;
          public AA(int a,int b) {
             this.a = a;
             this.b = b;
          }
       }只用来在不记得它的成员函数时用this,怎么可能不记得他的成员函数
      

  8.   

    this.a=a;时作区分才必须。
    this.method()基本上可以全部去掉
    但是
    class A{
       void method(A a){
           ....
       }
       class B{
          void innerMethod(){
             method(A.this); //这个OuterClassName.this是不可以省的,它是转型
          }
       }
    }
      

  9.   

    Sorry   因为一个类的成员函数或者成员变量太多,我说的是在可视化的环境下:  比方说JCreator 或者是 JBuiler . 这种IDE环境是可以有提示的.     试问你能够把JAVA所有的API或者是一个类的成员全部记下来且不会错吗?      当在当前类的范围内可以不加this,但加上this只是为了程序更加清晰:
      如果离开了当前的类范围当然只有声明你所要引用的对象啦:
         AA.java
         public class AA {
           private int a;
           private int b;
           
           public AA(int a,int b) {
             this.a = a;
             this.b = b;
           }    BB.java
           public class BB {
              public BB() {
              AA aa(3,5);//如果此处用this,引用的肯定是BB啦!!
           }
      

  10.   

    AA.java
         public class AA {
           private int a;
           private int b;
           
           public AA(int a,int b) {
             this.a = a;
             this.b = b;
           }    BB.java
           public class BB {
              public BB() {
              AA aa(3,5);//如果此处用this,引用的肯定是BB啦!!
           }public class BB {
              public BB() {
              AA aa(3,5);//如果此处用this,引用的肯定是BB啦!!
           }
    是什么用法
      

  11.   

    关于this的用法在"thinking in java"中主要讲了三点:
    1、在必须明确指出当前的object reference究竟为何时,才需要动用关键字this:
    例如:当向要返回目前的对象时,需要在return中这么写:
    public class Leaf {
      int i = 0;
      Leaf increment() {
        i++;
        return this;
      }
      void print() {
        System.out.println("i = " + i);
      }
      public static void main(String[] args) {
        Leaf x = new Leaf();
        x.increment().increment().increment().print();
      }
    } ///:~2、在构造函数中调用构造函数,如果某个class中有多个构造函数,有时候在需要在某个构造函数中调用另一个构造函数,以免重复代码,也可以使用this。
    例如:public class Flower {
      int petalCount = 0;
      String s = new String("null");
      Flower(int petals) {
        petalCount = petals;
        System.out.println(
          "Constructor w/ int arg only, petalCount= "
          + petalCount);
      }
      Flower(String ss) {
        System.out.println(
          "Constructor w/ String arg only, s=" + ss);
        s = ss;
      }
      Flower(String s, int petals) {
        this(petals);
    //!    this(s); // Can't call two!
        this.s = s; // Another use of "this"
        System.out.println("String & int args");
      }
      Flower() {
        this("hi", 47);
        System.out.println(
          "default constructor (no args)");
      }
      void print() {
    //!    this(11); // Not inside non-constructor!
        System.out.println(
          "petalCount = " + petalCount + " s = "+ s);
      }
      public static void main(String[] args) {
        Flower x = new Flower();
        x.print();
      }
    } ///:~3、如果方法的参数s和数据成员s的名称相同,会出现模棱两可的情况,也需要用到this,这种情况就是以上各位说的。 比如: wlz47(秋水沉舟)。
      

  12.   

    你们看到过this(a,b)的用法吗?这是最难的,不是在构造函数中用
      

  13.   

    你和你爸爸都在打球,都用了投篮的动作。 
    要是,class you extnds yourfather{ 
    this()//<------你的动作 
    super()//<--------你老爸的动作 
    }
    this的这种用法那位高人能句个例子,在下孤陋寡闻,没见国