javajavadoc

How to format code snippet in Javadoc with @ and { symbols inside?


This is what I'm trying to do:

/**
 * <pre>
 * {@code
 * &#64;XmlRootElement
 * public final class Page &#123;
 * &#125;
 * }
 * </pre>
 */

I'm expecting it to be formatted like:

@XmlRootElement
public final class Page {
}

But I'm getting:

&#64;XmlRootElement
public final class Page &#123;
&#125;

Replacing these HTML entities with real symbols (@, {, }) leads to javadoc warnings and absolutely incorrect formatting. What is a workaround?


Solution

  • This is how it finally works for me:

    /**
     * <pre>
     * &#64;XmlRootElement
     * public final class Page {
     * }
     * </pre>
     */