Overridden methods in JavaDoc

别来无恙 提交于 2019-11-30 10:41:42

[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:

If you want to use the JavaDoc of the overridden method, use {@inheritDoc}. F. e. :

/**
  * {@inheritDoc}
  */
@Override
public double getX() { ... }

Please notice that almost every overriden method also inherits the upper docs :) . You can read about it in the oracle docs (thanks for the hint @Steve Kuo) .

The Javadoc tool has the ability to copy or "inherit" method comments in classes and interfaces under the following two circumstances. Constructors, fields and nested classes do not inherit doc comments... (1) Automatically inherit comment to fill in missing text ... (2) Explicitly inherit comment with {@inheritDoc} tag

Use @see if you want to reference to a similar/important/... method. Example of the java.awt.Point class:

 /**
 * Returns the location of this point.
 * This method is included for completeness, to parallel the
 * <code>getLocation</code> method of <code>Component</code>.
 * @return      a copy of this point, at the same location
 * @see         java.awt.Component#getLocation
 * @see         java.awt.Point#setLocation(java.awt.Point)
 * @see         java.awt.Point#setLocation(int, int)
 * @since       1.1
 */
public Point getLocation() { ... }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!