Using the @Override
annotation is useful for two reasons :
class ParentClass { public boolean doSomething(){...} } class FirstChildClass extends ParentClass { public boolean doSomething(){...} // Noncompliant }
class ParentClass { public boolean doSomething(){...} } class FirstChildClass extends ParentClass { @Override public boolean doSomething(){...} // Compliant }
This rule is relaxed when overriding a method from the Object
class like toString()
, hashCode()
, …