previous |
start |
next
Overriding the equals Method
- equals tests for equal contents
- == tests for equal location
- Must cast the Object parameter to subclass
- public class Coin
{
public boolean equals(Object otherObject)
{
Coin other = (Coin)otherObject;
return name.equals(other.name) &&
value == other.value;
}
}
previous |
start |
next