java – What tags can I use to document my code?

Question:

I'm looking for better ways to document my code in Netbeans.

In addition to the well-known tags used in Javadoc, something caught my attention and piqued my curiosity.

Typing {@ brings up some documentation suggestions with tags I've never seen and I don't know what it's for. Some:

{@code}
{@docRoot}
{@link}
{@linkplain}
{@literal}

Would {@link} be a replacement for the @link tag? What are these other tags for?

Answer:

You can get a list of the main Javadoc tags from Wikipedia or you can get it from the official documentation .

tag Description where to use
@author Designer the author of the code Class, Interface, Enum
@version Specifies the software version Class, Interface, Enum
@since Functionality start date Class, Interface, Enum Field, Method
@see Link to another part of the documentation Class, Interface, Enum Field, Method
@stop Describes a parameter of a method method
@return Describes the return of a method method
@exception Describes an exception being thrown method
@throws Same as above * method
@deprecated Indicates the method is obsolete method
{@inheritDoc} Copy the description of the parent method Overriding Method
{@link reference} Establish a link to some resource Class, Interface, Enum Field, Method
{@value #STATIC FIELD} Describes a static grave static field

* Normally the throws tag is preferred when the method throws a checked exception .

These are the recommendations. Obviously you can use it however you like. Many people don't like to use certain tags that don't add relevant information to the documentation. Author is the most obvious of them. Authorship and creation date control should be controlled by version control software. But it depends on the culture of each team.

Scroll to Top