重写equals()方法和hashcode()方法
重写equals()方法
public boolean equals(Object other) {
if (this == other)
return true;
if (!(other instanceof User))
return false;
final User u = (User) other;
if(!name.equals(u.getName()))
return false;
if(!birthday.equals(u.getBirthday()))
return false;
if(!name.equals(u.getName()))
return false;
if(!name.equals(u.getName()))
return false;
return true;
}
重写hashcode()方法
public int hashCode() {
return Objects.hash(id, name, gender, age, birthday);
}