45

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

Oh Chin Boon
  • 23,028
  • 51
  • 143
  • 215

2 Answers2

51

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}.

Laurence Gonsalves
  • 137,896
  • 35
  • 246
  • 299
6

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.

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 `` 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. – Laurence Gonsalves Aug 15 '11 at 15:04