The @Override
annotation.
public class Shape {
double x, y;
...
@Override // Promise: Subsequent method overrides Object.toString();
public String toString() {
return "(" + x + "|" + y + ")";
}
}
public class Shape {
double x, y;
...
@Override // Error: method does not override a method from a supertype
public String toString(int value) {
return "(" + x + "|" + y + ")";
}
}
Explanation: The given method does not override Object.toString()
.