Overridden methods in JavaDoc

Alex Blundell picture Alex Blundell · Apr 9, 2013 · Viewed 53.7k times · Source

I'm documenting a Java program that I have developed, and wanted to know if JavaDoc will be generated for an inherited method (which is overridden) if I just document the superclass?

If I have a class called Vehicle with a drive() method in, and a sub-class called Car with the drive() method overridden, will the documentation for the Vehicles drive method be included in the Cars drive method if no Javadoc is put in the Car class?

Answer

Stephen C picture Stephen C · Apr 9, 2013

[I] wanted to know if JavaDoc will be generated for an inherited method (which is overridden) if I just document the superclass?

Yes. If you don't have javadoc comments on a subclass, javadocs will be be generated based on the superclasses javadoc.

If you define javadocs in the subclass they will replace the inherited javadocs, but you can use {@inheritDoc} to include the respective superclass javadoc comments in the subclass javadocs.

Reference: