package cod.mianxian.duixiang;
public class Ren {
private int age;
private String name;
Ren(int age , String name){
this.age=age;
this.name=name;
}
public void run() {
System.err.println(age+".."+name);
}
public boolean equals(Object object) {
if(!(object instanceof Ren)) {
throw new ClassCastException("类型错误");
Ren ren=(Ren)object;
return this.age=ren.age && this.name.equals(name);// boolean无法判断
}
}
}
|
|