Why is NetBeans showing me a hint whenever I try to return a string from a method. Such as-
public String toString(){
return "Circle: radius= "+radius+" color= "+color;
}
The hint says "add @Override Annotation
"
Why is NetBeans showing me a hint whenever I try to return a string from a method. Such as-
public String toString(){
return "Circle: radius= "+radius+" color= "+color;
}
The hint says "add @Override Annotation
"
The @Override
annotation tells the compiler that you are overriding that method which is previously defined in a super class.
It helps the compiler verifying if in deed there is such a method defined in the super class or not. If it is not defined, you will get a compiler error telling you that the method is not defined in the super class.
If you are truely overriding an existing method defined in the super class, your code should work with or without the @Override
annotation.