Alex Rivera | Logout

Code example with annotation in JavaDoc

Asked 2010-04-14T08:59:40.410
36

my JavaDoc doesn't work when I have a code example with an annotation.

Any suggestions?

/**
 * <pre>
 * public class Demo {
 *    @DemoAnnotation
 *    public void demoMethod() {
 *    }
 * }
 * </pre>
 */ 
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public @interface DemoAnnotation {
Edit
Report

1 Answer

55

A more general solution: {@literal @}

The {@literal} tag denotes literal text. The enclosed text is interpreted as not containing HTML markup or nested javadoc tags. For example, the doc comment text: {@literal a<B>c} displays in the generated HTML page unchanged: a<B>c -- that is, the <B> is not interpreted as bold.

Requires Java 5+

answered 2012-04-05T19:54:07.417

Your Answer