有没有一种方法可以从方法文档正文中添加对一个或多个方法参数的引用?类似于:
/**
* When {@paramref a} is null, we rely on b for the discombobulation.
*
* @param a this is one of the parameters
* @param b another param
*/
void foo(String a, int b)
{...}
<code>foo</code>
;你可以使用{@code foo}
。当您引用泛型类型(例如{@code Iterator<String>}
)时,这一点尤其重要 - - 确实比<code>Iterator<String></code>
好看!正如你可以在Java源代码的java.lang.String
类中看到:
/**
* Allocates a new <code>String</code> that contains characters from
* a subarray of the character array argument. The <code>offset</code>
* argument is the index of the first character of the subarray and
* the <code>count</code> argument specifies the length of the
* subarray. The contents of the subarray are copied; subsequent
* modification of the character array does not affect the newly
* created string.
*
* @param value array that is the source of characters.
* @param offset the initial offset.
* @param count the length.
* @exception IndexOutOfBoundsException if the <code>offset</code>
* and <code>count</code> arguments index characters outside
* the bounds of the <code>value</code> array.
*/
public String(char value[], int offset, int count) {
if (offset < 0) {
throw new StringIndexOutOfBoundsException(offset);
}
if (count < 0) {
throw new StringIndexOutOfBoundsException(count);
}
// Note: offset or count might be near -1>>>1.
if (offset > value.length - count) {
throw new StringIndexOutOfBoundsException(offset + count);
}
this.value = new char[count];
this.count = count;
System.arraycopy(value, offset, this.value, 0, count);
}
参数引用需要用<code></code>
标签括起来,这意味着 Javadoc 语法没有提供任何方法来执行此操作。(我认为 String.class 是 javadoc 的一个很好的使用示例。)
offset
和count
参数。 - Caleb Hulbert
@code
标签在 Javadoc - Tag Descriptions 中有描述。 请参见 JDK8 代码示例。 - pba