Valentino Verdi wrote:Hi guys, don't know if this is the right place for such a question.
If I want to instantiate an ordinary Inner Class (not Local), from inside the Outer Class, I can just type:
InnerClass innerObject = new InnerClass().
This is fine, but I can also type, to underline the fact that the inner object lives inside an Outer Class instance:
InnerClass innerObject = this.new InnerClass().
This is fine too.
Yeah, but not always. It doesn't work, if these instances are created within a static method. Try this
within a static method. Doesn't work.
Valentino Verdi wrote:
Now, it turns out that this second syntax does not work for Local Inner Classes (inside a method), I get an "identifier not found" (or kind of) error. If I just omit "this." everything works fine.
Any idea why for Local Inner Classes it is not possible to use the "this" reference?
Check the last line in the local inner method.
this refered here to the enclosing class object. And you can't access the (method-)local inner class from outside the method. Therefore ERROR.
Hope I could help.
Bob