class Base{
int oak=99;
}
public class Doverdale extends Base{
public static void main(
String argv[]){
Doverdale d = new Doverdale();
d.amethod();
}
public void amethod(){
//assign new value to inherited int oak, NO IMPACT!
new Doverdale().oak=9;
System.out.println(super.oak);//still 99
System.out.println(this.oak);//follow super.oak value
super.oak=19;
System.out.println(super.oak);//change to 19
System.out.println(this.oak);//Always follow super.oak?!
}
}
The output is
99
99
19
19
I understand that derived class Doverdale has an int field oak with a default value same with that of its parent class. Whenever the super int change its value, the Doverdale int oak will follow.
My question is how we can change the value of Doverdale int without affecting that of its parent class oak. Thanx in advance!