Comments


Comments are included in a program's code to improve readability, and are ignored by the Java compiler. Comments that span one or more lines are enclosed by /* and */. In the Circle program, lines 1–4 are an example of a multiline comment.

A single line comment is prefixed by //. A single line comment may be appended to an existing statement. An example of a single line comment in line 14 is


// area formula.

2.1.1 Javadoc

The javadoc tool, available as part of the Java SDK, parses documentation comments within a Java source file and produces an HTML document. Within the source file, such comments are included in a block beginning with /** and ending with */. Comment text is written in HTML format and will include tags, prefixed with a @, which can be used, for example, for headings such as author name and program version number, and for creating hypertext links. Document blocks are placed immediately before the class, method, or field they describe.

javadoc can be used for documenting one or more classes, packages, or both packages and classes. We will learn about packages in later part. For each class or package, javadoc will produce an HTML file (of the form class.html or package.html), as well as a number of supporting files (index.html, for example). The resulting documentation has the same format as the Java 2 Platform API Specification.

No comments:

Post a Comment