public class ExtendTheory{ public static void main(String[] args) { Son son=new Son(); } } class GrandPa{ String name="大头爷爷"; } class Father extends GrandPa { String name="大头爸爸"; } class Son extends Father{ String name="大头儿子"; }
首先加载类信息==从父类开始逐级向下==>GrandPa信息–> Father—->son
在堆中开辟 内存空间 —-> 储存GrandPa—>储存 Father—>储存son
Maybe you could buy me a cup of coffee.
Scan this qrcode
Open alipay app scan this qrcode, buy me a coffee!
Scan this qrcode
Open wechat app scan this qrcode, buy me a coffee!