How can you escape the @ character in javadoc?

Use the {@literal} javadoc tag:

/**
 * This is an "at" symbol: {@literal @}
 */

The javadoc for this will read:

This is an "at" symbol: @

Of course, this will work for any characters, and is the “officially supported” way of displaying any “special” characters.

It is also the most straighforward – you don’t need to know the hex code of the character, and you can read what you’ve typed!

Leave a Comment