结合对象的创建进行理解
package com.ysc.oop;
public class Pet {
public String name;
public int age;
public void shout(){
System.out.println("叫了一声");
}
}
package com.ysc;
import com.ysc.oop.Pet;
public class TestApplication {
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();
cat.name = "miaomiao";
cat.age = 3;
System.out.println(cat.name);
System.out.println(cat.age);
}
}