Java文档覆盖方法不会继承 [英] Java Documentation Override Method does not InheritDoc

查看:144
本文介绍了Java文档覆盖方法不会继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

覆盖其他方法的方法不会继承其覆盖方法的文档。有没有办法明确告诉它继承文档?

A method that overrides another method does not inherit documentation of the method it is overriding. Is there any way to explicitly tell it to inherit the documentation?

/**
  * {@inheritDoc}
  * 
  * This implementation uses a dynamic programming approach.
  */
@Override
public int[] a(int b) {
    return null;
}


推荐答案

根据 javadoc文档


继承注释发生在所有
三种可能的继承类型和接口
的情况下:

Inheriting of comments occurs in all three possible cases of inheritance from classes and interfaces:


  • 当类中的方法覆盖超类中的方法

  • 当界面中的方法覆盖超级界面中的方法

  • 当类中的方法实现接口中的方法

注释可以明确地继承使用 {@inheritDoc} 标签。如果没有为重写方法提供任何注释,则会隐式地继承注释。如果您愿意,继承评论的方面(例如参数,返回值等)可以被覆盖。

Comments can be explicitly inherited using the {@inheritDoc} tag. If no comments are provided for an overriding method, comments will be implicitly inherited. Aspects of the inheriting comments (e.g. params, return value, etc.) can be overridden if you so desire.

重要的是,您需要确保源文件包含具有要继承的注释的代码可用于javadoc工具。您可以使用 - sourcepath 选项。

Importantly, you need to make sure that the source file containing the code with the comment to be inherited is available to the javadoc tool. You can do this by using the -sourcepath option.

这篇关于Java文档覆盖方法不会继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆