创建对象内存分析
作者:互联网
package oop.demo01; public class Pet { public String name; public int age; //无参构造 public void shout(){ System.out.println("叫了一声"); } } ------------------------------------------------------- package oop.demo01; //一个项目应该只存在一个main方法 public class Application { public static void main(String[] args) { Pet dog = new Pet(); dog.name="旺财"; dog.age = 3; dog.shout(); System.out.println(dog.name); System.out.println(dog.age); Pet cat = new Pet(); } }
搜索
复制
标签:分析,System,name,Pet,dog,创建对象,内存,public,out 来源: https://www.cnblogs.com/sususyq-/p/16514181.html