假设您的班级有两种方法:
contains() and
containsSame()
Run Code Online (Sandbox Code Playgroud)
它们之间的区别是微妙的,你想把它作为Javadoc的一部分提到
在Javadoc中,如何通过名称引用同一类中的方法?
Paŭ*_*ann 56
使用@link内联标记,并使用前导引用该方法#.
/**
* ...
* This method is similar to {@link #contains()}, with the following differences:
* ...
*/
public boolean containsSame();
/**
* This method does ...
*/
public boolean contains();
Run Code Online (Sandbox Code Playgroud)
这个例子只有在实际上有一个contains()没有参数的方法时才有效(实际上,这似乎没那么有用).如果你只有一个contains带参数的方法,那么要么在括号中写入参数类型:
/**
* ...
* This method is similar to {@link #contains(Element)}, with the following differences:
* ...
*/
public boolean containsSame(Element e);
/**
* This method does ...
*/
public boolean contains(Element e);
Run Code Online (Sandbox Code Playgroud)
或者你可以省略括号:
/**
* ...
* This method is similar to {@link #contains}, with the following differences:
* ...
*/
public boolean containsSame(Element e);
/**
* This method does ...
*/
public boolean contains(Element e);
Run Code Online (Sandbox Code Playgroud)
如果您有多个名为contains(使用不同的参数列表)的方法,则此版本无法决定使用哪个(链接将跳转到其中任何一个,希望它们都在一起并执行类似的操作).
| 归档时间: |
|
| 查看次数: |
13010 次 |
| 最近记录: |