Skip to content

JavaDoc: Hassle-free embedded Code using @code

by on May 16, 2012

Do you know that scenario: You want to add example code to your Javadoc. You use the <pre>-tag but still you have to mess around with greater-than or less-than characters which need to be transformed to HTML entities.

Actually there is a solution since JDK 1.5 I was not aware of. There are two tags @code and @literal which will help you writing easy to maintain Javadoc-code:

 * Equation: {@literal i > j}.
 * Inline code: {@code getThat()}.
 * Multi line code:
 * <pre>{@code
 * doThis();
 * doThat();
 * }</pre>

From → Dev

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s