在下面的代码中:
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/