Is there any way to access a variable of an overridden class if a nested private method is involved?
In partiular, I want to know the value of String foo inside class B after the rename function was performend (see example below). I do not intend to change any of the functionality of the code of class A, this is solely about getting the value somehow.
I am free to edit class B but changing class A would only be an option to me if there really is no other way to achieve this.
public abstract class A {
protected void methodA() {
String foo = "bla";
foo = renameFunction(foo);
}
private String renameFunction(String incString)
{
return incString + "blub";
}
}
public class B extends A {
private String bar;
@Override
private void methodA() {
String foo = "bla";
foo = renameFunction(foo); //will not work as it's private
this.bar = foo;
}
}