CIS 35A: Introduction to Java Programming

Home | Green Sheet | Lectures | Assignments | FAQ | Grades

Packages

Packages
javadoc
use HTML

How to use HTML and javadoc tags in javadoc comments

  • Within a javadoc comment, you can code HTML tags to format the text that's displayed.
  • You can also include javadoc tags to include special entries in the documentation.

Common HTML tag used to format javadoc comments

HTML tag Description
<code></code> Displays the text between these tags with a monospaced font.

Common javadoc tags

Documentation comments may also include tags. Each tag appears on a separate line and includes specialinformation. Common tags are:

Javadoc tag Description
@author author Identifies the author of the class. Not displayed by default.
@version version Describes the current version of the class. Not displayed by default.
@param parameternameAndDescription Describes a parameter of a constructor or method.
@return descriptionDescribes the value that's returned by a method.
@throws exceptionTypeDescription Gives a description of the types of exceptions that are thrown by a method..

The Product class with comments that use HTML and javadoc tags

package murach.business;
import java.text.NumberFormat;
/**********************************************************
 * The <code>Product</code> class represents a product and is used
 * by the <code>LineItem</code> and <code>ProductDB</code> classes.
 * @author Joel Murach
 * @version 1.0.0
 **********************************************************/
public class Product
{
  private String code;
  private String description;
  private double price;
  /***********************************************************
   * Creates a <code>Product</code> with default values.
   ***********************************************************/
  public Product()
  {
    code = "";
    description = "";
    price = 0;
  }
  /***********************************************************
   * Sets the product code to the specified <code>String</code>.
   * @param code A <code>String</code> for the product code.
   ***********************************************************/
  public void setCode(String code)
  {
    this.code = code;
  }
  /***********************************************************
   * Returns a <code>String</code> that represents the product code.
   * @return A <code>String</code> for the product code.
   ***********************************************************/
  public String getCode()
  {
    return code;
  }
  ...
Previous | Add comments | use HTML | Generate documentation | View documentation | Next