这个
Home.this引用
Home该类的当前实例。
此表达式的正式术语似乎是qualified
this,如Java语言规范的15.8.4节所引用。
在一个简单的类中,说
Home.this和
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对象返回。
此表达式的正式术语是类文字,如Java语言规范的15.8.2节所引用。
在大多数情况下,此表达式在使用反射时使用,并且需要一种方法来引用类本身而不是类的实例。



