I learned that == checks if the references being compared are the same,, while .equals() compares the two states. So then why can we use == inside the .equals() method?
Like for example:
public boolean equals(Object o){
//cast o to SimpleBankAccount
SimpleBankAccount b = (SimpleBankAccount)o;
//check if all attributes are the same
if ((this.balance == b.balance) && (this.accountNumber == b.accountNumber)){
return true;
}
else{
return false;
}
}
Why would the this.balance and b.balance have the same reference?