What is the difference between {@code memberData}
and <code>memberData</code>
in JavaDoc
Asked
Active
Viewed 7,350 times
45

Oh Chin Boon
- 23,028
- 51
- 143
- 215
2 Answers
51
There are two main differences:
{@code ...}
is more concise: easier to read (and type).Text within
{@code ...}
will be automatically HTML-escaped for you.For example,
{@code List<String>}
is equivalent to<code>List<String></code>
.
See also the documentation for {@code}
.

Laurence Gonsalves
- 137,896
- 35
- 246
- 299
-
2The automatic HTML-escaping is especially important for readability of the source code. – Christian Semrau Aug 15 '11 at 15:03
-
Thanks. The escaping thing is vital to understand that there is actually a difference between the two. – Andrew Tobey Sep 11 '14 at 04:50
6
The {@code}
is equivalent to <code>
except that it uses allows you to use angle brackets <
and >
instead of HTML-entities <
and >
.
Example:
{@code LinkedList<String>}
The Javadoc knows how to interpret it as <code>
without the need of generating HTML.

Buhake Sindi
- 87,898
- 29
- 167
- 228
-
`{@link}` creates a link. `{@code}` normally does not. Your description of `
` is also a bit funny... From Javadoc's point of view `
– Laurence Gonsalves Aug 15 '11 at 15:04` is just an HTML tag that gets passed through, so how it's rendered is up to the browser, while `{@code}` is a directive that Javadoc actually processes on its own. Also, I'm pretty sure `{@code}` produces `
` tags in the output too, so the rendering in the browser wil be the same.