我想为评论块写一个超链接/链接,我可以从代码的任何部分引用。
例如,我在课堂上提到了一些评论:
/**
* Really long comments with some case based detail
*/
//Code goes here...
//Code goes here...
// Hey I want you to please have a look at **This Comments** please before making any changes ...
public void myMethod(){....
// Hey I want you to please have a look at **This Comments** please before making any changes ...
public void yetAnotherMethod(){....
For above the **This Comments** should be a link to details mentioned at the top.
答案 0 :(得分:0)
您可以使用@link
和@see
javadoc标记插入指向其他类型或字段的链接。
您还可以指定链接的文本,如下所示:
{@link ClassName#fieldName Text to display}
@see ClassName#fieldName Text to display
示例:
我使用字段来定义注释,但您可以链接到Class,method,field等:
/**
* Important to know that...
*/
private static final byte IMPORTANT_NOTE = 0;
/**
* Before making changes, see {@link #IMPORTANT_NOTE Important note}.
*/
public void myMethod() {}
/**
* @see #IMPORTANT_NOTE Important to check this!
*/
public void myMethod2() {}
您还可以使用@value
将静态字段的值内联到javadoc中,例如:
private static final String IMPORTANT_NOTE = "Important to know that...";
/**
* See this important note: {@value #IMPORTANT_NOTE}
*/
public void myMethod() {}