I. Purpose
In order to better combine code and documents and better manage code
Ii. Syntax
All javadoc commands can only start with "/**" comments, and end with "*/" like general comments. Use javadoc
There are two main methods: Embed HTML, or use "Doc tag )". The so-called "document tag" is
Commands starting with "@", and the "@" character must be placed at the beginning of the comment line (that is, after the leading "*" is ignored)
). The "inline Doc tag" can appear anywhere in the javadoc comment,
They also start with the "@" character, but must be enclosed in curly brackets.
There are three types of annotation documents, which correspond to the three elements after the annotation position: Class, variable, and method. That is
Class annotation is located just before the class definition; variable annotation is located just before the variable definition; and method definition is also located
Before the method definition. As shown in the following simple example:
/** A class comment */
Public class doctest {
/** A variable comment */
Public int I;
/** A method comment */
Public void F (){}
}
Note that javadoc can only annotate documents for "public (public)" and "protected (protected)" members."Private
(Private) "and comments of accessible members in the package will be ignored, so they will not be seen in the output results.
(However, you can use-private to mark the members so that they can be processed together ).This makes sense because
Only public and protected members can be used outside the file, which is expected by the client programmer. As
All comments made to the class are included in the output result.
You can also set corresponding formats in myeclipse to facilitate code management.
Embedded HTML
Javadoc embeds the HTML command into the HTML document generated by it. This allows you to make full use of HTML
Yes. Of course, the main purpose is to format the code. The following is an example:
/**
* <PRE>
* System. Out. println (new date ());
* </PRE>
*/
You can also use HTML in other Web documents to format common text as described by yourself.
/**
* You can <em> even </em> insert a list:
* <Ol>
* <Li> item one
* <Li> item two
* <Li> item three
* </OL>
*/
Note: In document comments, asterisks and leading spaces at the beginning of each line are discarded by javadoc. Javadoc
All contents are reformatted to make them look the same as the standard document. Do not use titles in embedded HTML
For example, Disturbance.
All types of annotation documents-classes, variables, and methods-support embedded HTML.