This is what I'm trying to do:
/**  * <pre>  * {@code  * @XmlRootElement  * public final class Page {  * }  * }  * </pre>  */   I'm expecting it to be formatted like:
@XmlRootElement public final class Page { }   But I'm getting:
@XmlRootElement public final class Page { }   Replacing these HTML entities with real symbols (@, {, }) leads to javadoc warnings and absolutely incorrect formatting. What is a workaround?
{@code} is a Javadoc tag that came with Java 5. A code snippet embedded within {@code} will display our special characters correctly so they don't need to be manually escaped. However, indentation and line breaks will be lost. This can be rectified by using {@code} together with <pre> , though (see next section).
There are no real restrictions on the use of HTML in Javadoc comments. The Javadoc documentation states: Comments are written in HTML - The text must be written in HTML, in that they should use HTML entities and can use HTML tags.
This is how it finally works for me:
/**  * <pre>  * @XmlRootElement  * public final class Page {  * }  * </pre>  */ 
                        <pre> <code> {@literal@}Override public String toString() {     return "blah"; } </code> </pre>   This works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With