java - javadoc 如何知道每个文档注释针对哪个方法?

标签 java comments javadoc

在下面的代码中:

public class Rectangle {
    private double length;
    private double width;

    /**
     * The setLength method stores a value in the
     * length field.
     * @param len The value to store in length.
     * 
     */

    public void setLength(double len){
        length  = len;
    }

javadoc 如何将我的注释与 setLength 方法关联起来?仅仅是因为注释就在方法声明之前吗?

最佳答案

是的,这确实只是因为注释位于方法声明之前。

虽然据我所知没有明确说明,但它是根据 JavaDoc 工具如何工作的描述得出的,请参阅 How to Write Doc Comments for the Javadoc Tool

具体来说,关于 Source Files 的部分:

The Javadoc tool can generate output originating from four different types of "source" files:

  • Source code files for Java classes (.java) - these contain class, interface, field, constructor and method comments.
  • [...]

A doc comment is written in HTML and must precede a class, field, constructor or method declaration.

关于java - javadoc 如何知道每个文档注释针对哪个方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53762809/

相关文章:

java - 文件并行流

angularjs - 如何向 Angular 模板添加注释(针对开发人员,而不是在输出 HTML 中)?

c++ - 在 Visual Studio Enterprise 2017 中禁用自动生成的评论

javascript - 为什么 Javascript 会忽略单行 HTML 注释?

java - IntelliJ IDEA 类 Ghostdoc 插件

java - javadoc 的默认值

android - Gradle Javadoc 失败并显示 "error: package ... does not exist"

java - 根据 boolean 值对列表进行部分排序

java - 多态性和 DTO 对象创建

java - 如何使用 spring 缓存抽象返回条目数