How can I hyperlink one comment from another comment location in javadoc
I want to write a hyperlink / link for a comment block that I can link to any part of the code.
For example, I mentioned some comments on top of the class:
/**
* 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.
+3
source to share
1 answer
Link / Link
You can use tags @link
and @see
javadoc to embed references to other types or fields.
You can also specify link text like this:
{@link ClassName#fieldName Text to display}
@see ClassName#fieldName Text to display
Examples:
I used a field to define a comment, but you can refer to a class, method, field, etc:
/**
* 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() {}
Embedding
You can also embed static field values ββin javadoc with @value
, for example:
private static final String IMPORTANT_NOTE = "Important to know that...";
/**
* See this important note: {@value #IMPORTANT_NOTE}
*/
public void myMethod() {}
0
source to share