this refers to an instance itselffor example,
class Hello
{
String name; //#1
Hello(String name) //#2
{
//this.name refers to the name field on line #1
//name refers to the name parameter on line #2
this.name = name;
} Hello()
{
this("Hello"); //calls the previous constructor
}
}
class Hello
{
String name; //#1
Hello(String name) //#2
{
//this.name refers to the name field on line #1
//name refers to the name parameter on line #2
this.name = name;
} Hello()
{
this("Hello"); //calls the previous constructor
}
}
int i;
public MYClass(int i){
this.i=i; //注意这两个i是不一样的
}
}this就是“俺/我/吾”,小衲以为就是“我相”!什么东西比“我相”厉害呢?就是“本相”!Java中的“本相”是什么呢?小衲以为是java.lang.Class:
java.lang.Class 本相 = this.getClass();
关于“我相”和“本相”的关系,详见鸠摩智在天龙寺发表的
讲话以及JLS(Java Language spec) 2nd Edition:http://java.sun.com/docs/books/jls/
你的例子我能理解
可是你的话我却不懂是什么意思,
呵呵
能解释一下吗?