java - Can I access the "secondary this" from an inner class? -


this question has answer here:

i have basic classes

abstract class unit {     unit target;     abstract class unitai {/*...*/} } 

from these, have derived

class infantry extends unit {     class infantryai extends unitai {/*...*/} } 

can class infantryai somehow secondary(implicit) this used accessing members of it's surrounding class infantry?

specifically, needs determine if surrounding class infantry being targetted target, this:

if (/*secondary_this.*/target.target == secondary_this) 

or, generally, unit.

you can access outer this prepending classname:

infantry.this.target; //"this" of infantry class inside infantryai unit.this.target; //"this" of unit class inside unitai 

this doesn't work static nested classes though don't belong instance of outer class.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -