Some example tags
Here are some of the javadoc tags available for code documentation. Before trying to do anything serious using javadoc, you should consult the javadoc reference in the downloadable JDK documentation to get full coverage of the way to use javadoc.
@see: referring to other classes
The @see tag allows you to refer to the documentation in other classes. Javadoc will generate HTML with the @see tags hyperlinked to the other documentation. The forms are:
Each one adds a hyperlinked See Also entry to the generated documentation. Javadoc will not check the hyperlinks you give it to make sure they are valid.
Very similar to @see, except that it can be used inline and uses the label as the hyperlink text rather than See Also.
Produces the relative path to the documentation root directory. Useful for explicit hyperlinking to pages in the documentation tree.
Inherits the documentation from the nearest base class of this class into the current doc comment.
This is of the form:
in which version-information is any significant information you see fit to include. When the -version flag is placed on the javadoc command line, the version information will be called out specially in the generated HTML documentation.
This is of the form:
in which author-information is, presumably, your name, but it could also include your email address or any other appropriate information. When the -author flag is placed on the javadoc command line, the author information will be called out specially in the generated HTML documentation.
You can have multiple author tags for a list of authors, but they must be placed consecutively. All the author information will be lumped together into a single paragraph in the generated HTML.
This tag allows you to indicate the version of this code that began using a particular feature. Youll see it appearing in the HTML Java documentation to indicate what version of the JDK is used.
This is used for method documentation, and is of the form:
@param parameter-name description
in which parameter-name is the identifier in the method parameter list, and description is text that can continue on subsequent lines. The description is considered finished when a new documentation tag is encountered. You can have any number of these, presumably one for each parameter.
This is used for method documentation, and looks like this:
in which description gives you the meaning of the return value. It can continue on subsequent lines.
Exceptions will be demonstrated in Chapter 9. Briefly, they are objects that can be thrown out of a method if that method fails. Although only one exception object can emerge when you call a method, a particular method might produce any number of different types of exceptions, all of which need descriptions. So the form for the exception tag is:
@throws fully-qualified-class-name description
in which fully-qualified-class-name gives an unambiguous name of an exception class thats defined somewhere, and description (which can continue on subsequent lines) tells you why this particular type of exception can emerge from the method call.
This is used to indicate features that were superseded by an improved feature. The deprecated tag is a suggestion that you no longer use this particular feature, since sometime in the future it is likely to be removed. A method that is marked @deprecated causes the compiler to issue a warning if it is used.