The examples in this article describe the usage of super keyword in java. Share it with everyone for your reference. The specific method analysis is as follows:
super keyword: Use super in java to refer to components of a base class.
The program code is as follows:
class FatherClass{ public int value; public void f(){ value = 100; System.out.println("FatherClass.value:"+value); }}class ChildClass extends FatherClass{ private int value; public void f(){ super.f(); value=200; System.out.println("ChildClass.value:"+value); System.out.println(value); System.out.println(super.value); }} public class TestInHerit{ public static void main(String args[]){ ChildClass cc = new ChildClass(); cc.f(); }}The output is as shown below:
The memory distribution is shown in the figure below:
I hope this article will be helpful to everyone’s Java programming.