Other than a couple of syntax errors, the implementation is not incorrect. However, the conversions to string are unnecessary:
return other.getRow() == getRow() && other.getColumn() == getColumn();
Other points:
The
if (this == obj)
check is redundant.The
if (getClass() != obj.getClass())
check may or may not be desirable, depending on whether you intend to ever subclassField
(I note that it is not declaredfinal
).
Last but not least, having overridden equals()
, you should also override hashCode()
. See What issues should be considered when overriding equals and hashCode in Java? for a discussion.