There is something like this:

Class parent { public child c=new child(); public void load(){ .....К этому методу надо добраться из дочернего объекта, созданного из дочернего класса child... } class child { public void save(){ ...вот отсюда надо получить доступ к объекту(или его методу load()), созданному из parent класса: то есть Big.load(); .... } } } parent Big= new parent(); 

How to solve this problem and is it possible?

    1 answer 1

    This is done via callback. Let's start with the child class ChildClass. In it, you declare the interface

     interface SomeListener { void load() } 

    Create a variable for this interface.

     SomeListener listener; 

    and the actual method of determining the listener

     public void setListener(SomeListener listener){ this.listener = listener; } 

    Now the base class and in it you implement the load method.

     Class BaseClass implements ChildClass.SomeListener{ public void load(){ // код } } 

    Now in first class when calling

     listener.load() 

    will call the class from the upper class

    • I add that from the inner class free access to the parent class. Yesterday the question was not formatted and I did not notice it - plesser