I noticed a piece of code that I looked at that the author used:
class MainClass
{
protected int someVar = 1;
private SomeClass someClass = new SomeClass(this, new SomeActionListener() {
protected void onAction() {
MainClass.this.someVar ++;
}
});
public MainClass()
{
}
}
Notice how he used MainClass.thisto get the correct 'this' context to change the scope back to MainClass. I have never seen this before - can anyone explain?
source
share