Can anyone tell me if this code:
public class OvTester {
@Override
public int hashCode() {
return toString().hashCode();
}
}
That code overrides the hashCode()
method form the base Object
class.
The toString()
method still has the original implementation.
To override the toString()
, you do the following:
@Override
public String toString() {
//Your own toString() implememntation here
}
As long as the method in the child class has the same name and signature as the method in the parent class, AND the method in the parent class is NOT private it will be overidden(regardless of the presence of the annotation @Override
)