java - Within object B, how to access an object A that has created object B? -


my code of form below:

public class outer {      protected int data;     protected inner inner;      protected void run() {         inner = new inner();     }  }  public class inner extends outer {      protected getouterdata() {         ...     } } 

an inner object created within method of class outer. within inner object, there way access data of instance of class outer has created inner object?

edit: realise can pass outer object inner object via constructor wondering if there way?

edit2: passing object via constructor ok i'm doing.

public class outer {      protected int data;     protected inner inner;      protected void run() {         inner = new inner(this);     }  }  public class inner extends outer {     private outer parent;     inner(outer parent) {         this.parent = parent     }      protected getouterdata() {         return parent;     } } 

Comments

Popular posts from this blog

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -

javascript - Restarting Supervisor and effect on FlaskSocketIO -

php - Mongodb connectivity error -