面向对象
创建对象内存分析
package com.oop.demo03;
public class Application {
public static void main(String[] args) {
Pet dog = new Pet();
dog.name = "wawa";
dog.age = 3;
dog.shout();//叫了一声
System.out.println(dog.name);//wawa
System.out.println(dog.age);//3
}
}
package com.oop.demo03;
public class Pet {
public String name;
public int age;
//无参构造
public void shout() {
System.out.println("叫了一声");
}
}