Search code examples
javajavadocabstractoverriding

Javadoc creates 'Specified by' heading


Given the following:

abstract class A {
  abstract String toString()
}

class B extends class A {
  @Override
  toString() {
    //implement method here
  }
}

if I run javadoc on class B, it does not generate an "Overrides:" subheading, but rather a "Specified by:" subheading, even after checking that the method does indeed override another by using the @Override annotation. Why is an "Overrides:" subheading not generated in this case? Any clarification on this would be appreciated.


Solution

  • "Overrides" is used if an implementation is overridden.

    For specifications by abstract methods and methods in interfaces, "Specified by" is applicable.

    Both can appear in parallel, i.e., when an abstract class implements something specified by an interface and the concrete subclass overrides this method. See clear in java.util.AbstractList.