Javadoc is a tool to help produce documentation of Java classes. Javadoc is a standard for documenting the author of the code, method parameters and method return values, classes and instance variables.
/**
and ends with a start character followed by a forward slash: */
.Javadoc tags are used within the javadoc comments for documenting specific parts of a class or method. These tags must appear at the beginning of a line. Here are the most common Javadoc tags:
/** * This class represents a rectangle. Each rectangle has a specific length and width. * @author CS1027 Lecture Notes */ public class Rectangle { /** * Length of the rectangle */ private int length; /** * Width of the rectangle */ private int width; /** * Constructor creates a rectangle with the given length and width * @param len length of the rectangle * @param wid width of the rectangle */ public Rectangle(int len, int wid) { length = len; width = wid; } /** * Accessor method to get the length of the rectangle * @return length of the rectangle */ public int getLength() { return length; } }
Since Javadoc outputs HTML-based documentation, you can also put HTML tags within the comments, such as:
<b>text to be displayed</b> in boldface <p>the beginning of a new paragraphExample:
/** * This is a <b>Javadoc</b> comment. */
In Eclipse, select Project, Generate Javadoc to create the HTML documentation based on the Javadoc comments of all classes within the project. The HTML documentation can be displayed in a browser such as Internet Explorer; index.html is the starting point of the documentation.