I ran into an interesting (and very frustrating) issue with the equals()
method today which caused what I thought to be a well tested class to crash and cause a
If you use eclipse just go to the top menu
Source --> Generate equals() and hashCode()
in Android Studio is alt + insert ---> equals and hashCode
Example:
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Proveedor proveedor = (Proveedor) o;
return getId() == proveedor.getId();
}
@Override
public int hashCode() {
return getId();
}