"this" means the current object, the instance we are currently running a method on.
Beware, inside an (anonymous) inner class, "this" refers to the inner class, not the usual enclosing one. If the outer class were called MyOuter, you could get at its this with "MyOuter.this".
Example:
public class MyClass { private String outerClassField = "some value"; public void outerClassMethod() { someObject.addMyListener(new MyListener() { public void processEvent(MyEvent e) { MyClass.this.outherClassField; } }); } }
沒有留言:
張貼留言