Skip to main content
Engineering LibreTexts

14.6: Javadoc Tags

  • Page ID
  • In Section 4.9, we discussed how to write documentation comments using /**. It’s generally a good idea to document each class and method, so that other programmers can understand what they do without having to read the code.

    To organize the documentation into sections, Javadoc supports optional tags that begin with the at sign (@). For example, we can use @param and @return to provide additional information about parameters and return values.

     * Tests whether x is a single digit integer.
     * @param x the integer to test
     * @return true if x has one digit, false otherwise
    public static boolean isSingleDigit(int x) {

    Figure 6.6.1 shows part of the resulting HTML page generated by Javadoc. Notice the relationship between the source code and the documentation.

    HTML documentation for isSingleDigit.

    Figure \(\PageIndex{1}\): HTML documentation for isSingleDigit.

    Methods with multiple parameters should have separate @param tags that describe each one. Void methods should have no @return tag, since they do not return a value.