In the code snippet shown below, an inner class inherits an outer class itself.
package test;
class TestInnerClass {
private String value;
public
In the above case there are 2 different relations between TestInnerClass and InnerClass.
But there is a little twist in story.. there are two objects! and the problem is that we are putting "Another Value" into different object! and printing the value from the old one..
First Object:
public static void main(String[] args) {
new TestInnerClass("Initial value").callShowValue();
}
Above method in Test Class creates an instance of TestInnerClass with "Initial value"
second Object:
public void callShowValue() {
new InnerClass("Another value").showValue();
}
Since the InnerClass is extending the TestInnerClass another new Instance of TestInnerClass is created with "Another Value". But we are printing the value from old object not the second one.