Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between {@code memberData} and <code>memberData</code> in JavaDoc

Tags:

java

javadoc

What is the difference between {@code memberData} and <code>memberData</code> in JavaDoc

like image 935
Oh Chin Boon Avatar asked Aug 15 '11 14:08

Oh Chin Boon


People also ask

What does @code mean in Javadoc?

{@code} is a Javadoc tag that came with Java 5. A code snippet embedded within {@code} will display our special characters correctly so they don't need to be manually escaped. However, indentation and line breaks will be lost. This can be rectified by using {@code} together with <pre> , though (see next section).

How do you link a method in Javadoc?

Javadoc provides the @link inline tag for referencing the members in the Java classes. We can think of the @link tag as similar to the anchor tag in HTML, which is used to link one page to another via hyperlinks. Similar to the anchor tag, the path_to_member is the destination, and the label is the display text.

How do you write a good Javadoc comment?

Use the standard style for the Javadoc comment Javadoc only requires a '/**' at the start and a '*/' at the end. In addition to this, use a single star on each additional line: /** * Standard comment. */ public ... /** Compressed comment.


2 Answers

There are two main differences:

  1. {@code ...} is more concise: easier to read (and type).

  2. Text within {@code ...} will be automatically HTML-escaped for you.

    For example, {@code List<String>} is equivalent to <code>List&lt;String&gt;</code>.

See also the documentation for {@code}.

like image 122
Laurence Gonsalves Avatar answered Sep 22 '22 04:09

Laurence Gonsalves


The {@code} is equivalent to <code> except that it uses allows you to use angle brackets < and > instead of HTML-entities &lt; and &gt.

Example:

{@code LinkedList<String>} 

The Javadoc knows how to interpret it as <code> without the need of generating HTML.

like image 26
Buhake Sindi Avatar answered Sep 20 '22 04:09

Buhake Sindi