Hi All.. I need a clarification regarding innner classes Please go through below code:
After explicitly assiging null value to outer class reference variable.. how it still able to access variable i? why relation ship not borken between inner object and outer object...even after assigning null to outer object?
Is my self satisfaction answer correct? Inner class object does't depend on outer class reference...to invoke outer class member... becuase the outer instance address already known to inner onject when it is instantied..
Thus inner object can access outer member even after outer object assigned to 'null'.
Is it possible to break relationship?
Thank you for reading my big query... I will be greatful for your comments...
An inner class (non static) instance always has an associated instance of an outer class.
Setting a class variable to null - does not change anything for the instance! If another variable (in this case the inner class) holds a reference (here indirectly) to the class instance, the instance exists. It stays and is not even eligible for garbage collection.