对象实例化过程
2020-05-01 11:41:23 0 举报
java
作者其他创作
大纲/内容
3、person null
10、初始化结束后,将堆内存的地址赋值给引用变量,然后子类的构造函数方法出栈
方法区
8、执行后弹出
2、Person.class
Person
extends
int age = 0String name = nullint skill = 0String postion =null
栈内存
6、子类构造方法进栈
CAD404
3、person CAD404
8、父类构造方法进栈
5、对对象中的属性进行默认初始化(包括父类)
9、显示初始化子类的属性int age = 10000String name = \"monkey King\"
Person person = new Person();
7、显示初始化父类的属性int skill = 2String postion =null
1、God.class
11、执行后弹出
堆内存
public class Person extends God{private int age = 10000;private String name = \"monkey King\";Person(){super();System.out.println(\"Person Class Construtor\");}}
God
4、在堆内存中开辟内存空间并分配地址:CAD404
public class God{private int skill= 2;private String postion;God(){System.out.println(\"God Class Construtor\");}}
0 条评论
下一页