内存图
2021-01-27 21:27:56 2 举报
练习
作者其他创作
大纲/内容
方法区
Applicationmain()常量池:旺财
静态方法区static:和类一起加载
dog:引用变量名
cat:引用变量名
堆
Petnameageshout()
new Pet():0x00001name = nullage = 0shout()
栈
public class Application { public static void main(String[] args) { Pet dog = new Pet(); dog.name = \"旺财\"; dog.age = 3; dog.shout(); Pet cat = new Pet(); }}
main()
public class Pet { public String name; public int age; public void shout() { System.out.println(\"叫了一声\"); }}
new Pet():0x00001name = \"旺财\"age = 3shout()
0 条评论
下一页