I am a Java beginner and I was trying to implement an equals method in an Address Class that I have made.
public class Address {
protected String validFrom;
protected String validTo;
public boolean equals(Object otherObject) {
if(otherObject == null)
return false;
else if
(getClass( ) != otherObject.getClass( ))
return false;
else
Address otherAddress = (Address) otherObject;
return (validFrom.equals(otherAddress.validFrom) && validTo.equals(otherAddress.validTo));
}
However I am getting an error at
Address otherAddress = (Address) otherObject;
The error is :
Address cannot be resolved to a variable