public static void main(String[] args) {
compareDogs();
}
public static void compareDogs(){
Dog dog1 = new Dog("哈士奇", 5);
Dog dog2 = new Dog("哈士奇", 5);
Dog dog3 = null; //dog3 是空值
System.out.println("这两只狗一样吗?" + dog1.equals(dog2));
System.out.println("这两只狗一样吗?" + dog1.equals(dog3));
}
}
class Dog{
String breed;
int age;