重写equals方法
重写equals必须重写hashCode
public boolean equals(Object obj){ if(obj instanceof Name){ Name name = (Name) obj; return (firstName.equals(name.firstName))&&(lastName.equals(name.lastName)); } return super.equals(obj); } public int hashCode(){ return firstName.hashCode(); }