class Person{ //为什么系统提示我Person类已经定义,,什么意识
private String name;
private int age;
public Person(String name,int age){
this.setName(name);
this.setAge(age);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
public class Demo5_47 {
public static void main(String[] args) {
Person per=new Person("wuliehao",30);
Person per1=new Person("zhangshan",30);
if(per.getAge()==per1.getAge()&&per.getName().equals(per1.getName())){
System.out.println("两个对象相等");
}
else{
System.out.println("两个对象不想等");
}
}
}
天启之魂
相关分类