首页
Home.this指的是Home类的当前实例。
此表达式的正式术语似乎是Qualified this,如Java语言规范的第15.8.4节中所述。
在一个简单的类,说Home.this,这将是等价的。此表达式仅用于存在内部类的情况,并且需要引用封闭类。
例如:
class Hello {
class World {
public void doSomething() {
Hello.this.doAnotherThing();
// Here, "this" alone would refer to the instance of
// the World class, so one needs to specify that the
// instance of the Hello class is what is being
// referred to.
}
}
public void doAnotherThing() {
}
}
Home.class
Home.class将返回Home类的表示作为Class对象。
此表达式的正式术语是class literal,如Java语言规范的第15.8.2节中所述。
在大多数情况下,当使用reflection时,将使用此表达式,并且需要一种方法来引用类本身,而不是类的实例。