I am writing an equals method in which two names are considered equal if they have the same first, middle, and last names. However, I keep getting the error
"This class defines a covariant version of the equals() method, but inherits the normal equals(Object) method defined in the base java.lang.Object class. The class should probably define a boolean equals(Object) method."
and when I change it to Object other as the parameter, I get a "no such method" error.
public boolean equals(Name other) {
boolean sameFirstName = firstName.equals(other.firstName);
boolean sameMiddleName = middleName.equals(other.middleName);
boolean sameLastName = lastName.equals(other.lastName);
if (sameFirstName && sameMiddleName && sameLastName) {
return true;
}
return false;
}