I thought I'd be a good boy and use Commons Lang utilities to implement toString(), hashCode() and equals(). Spot the mistake here:
@Override
public int hashCode() {
return new HashCodeBuilder(13, 73).append(field1).append(field2).hashCode();
}
Any ideas? Here's the corrected version:
@Override
public int hashCode() {
return new HashCodeBuilder(13, 73).append(field1).append(field2).toHashCode();
}
An easy mistake to make when using an IDE with auto-complete.
Luckily I was saved by my unit tests!
1 comment:
toHashCode()?
Post a Comment