Reputation: 23
My question is how do i gain access to my getters for the object o. It is an instance of BankTransaction but when i try to for example use o.getSender() I recieve an error.
@Override
public boolean equals(Object o) {
if (this instanceof BankTransaction && o instanceof BankTransaction) {
return true;
} else {
return false;
}
}
Upvotes: 1
Views: 46
Reputation: 201487
You have the first part down. Just add a cast if o
is of the right type.
if (o instanceof BankTransaction) {
BankTransaction bt = (BankTransaction) o;
// ...
}
Upvotes: 2