package Store;
public class Child extends Parent {
private String test = "";
public void ontest() {
this.test = "tryyyysssssssssss";
System.out.println("in constructer: " + this.test);
}
public String gettt() {
System.out.println("in child: " + this.test);
return this.test;
}
}
public abstract class Parent {
Parent() {
ontest();
}
public void ontest() {
}
public String get() {
System.out.println(gettt());
return "test";
}
public abstract String gettt();
}
public class StoreString {
public static void main(String[] args) {
Child s = new Child();
System.out.println("vaaaa:" + s.get());
}
}
output is:
in constructer: tryyyysssssssssss
in child:
vaaaa:test
My question:
I would like to use saved value of attribute test in Child class in method getttt(). I am not sure why value of test is blank in gettt method.
Could any one help me what is missing here?