/*class对象的属性影响行为*/ class Dog{ int size; String name; void bark(){ if(size > 60){ System.out.println("汪汪汪汪汪"); }else if(size > 14 ){ System.out.println("汪汪汪"); }else{ System.out.println("嗷嗷嗷"); } } } public class Duixiangzhuangtaihexingwei { public static void main(String[] args) { Dog dog1 = new Dog(); dog1.name = "旺财"; dog1.size = 100; Dog dog2 =new Dog(); dog2.name = "壮丁"; dog2.size = 20; Dog dog3 = new Dog(); dog3.name = "小旦"; dog3.size = 5; dog1.bark(); dog2.bark(); dog3.bark(); } }