Working with document annotations (Javadoc)

Source: Internet
Author: User

Believe that as a Java program ape, almost everyone has used javac,java such a command bar. Think of our usual Java Help document (API), it feels good to use, in fact, it is using the Java command Javadoc made. Here's a quick introduction to how this command works:

First of all, in Java with three kinds of annotation, in order to use Javadoc to generate documents and add the comment information into the document, it is necessary to use this way:

1 /** 2   * 3   */

The second is where the annotation information should be placed. 1. The comments on the class are placed before the class declaration; 2. Comment on the method before the method declaration; Here is a simple example:

1  PackageCom.review.chapter3;2 3 /**4 * classname:usejavadoc<br>5 * Description: Description of Java Chinese document through Usejavadoc class notes <br>6 * Company:zhouxy7  * @authorZhouxy8  * @version201408299  *Ten  */ One  Public classUsejavadoc { A      PublicString name; -      -     /** the * This is the constructor of the Usejavadoc class -      * @paramName Parameter -      */ -      PublicUsejavadoc (String name) { +          This. Name =name; -     } +      A      at     /** - * This is a description of the GetAll method -      * @paramNumber of Numbers -      * @returnQuantity -      */ -      Public intGetAll (intNumber ) { in          -         returnNumber ; to     } +}

In the above code, some comments are followed by <br> tags, and some do not, because the @ symbol comes with a newline character, so use @ does not have to add <br> tags.

The following is generated using the Javadoc command. First use the shortcut key win+r, type cmd in the dialog box, switch to the directory saved by the file, and then three different ways (assuming you want to save the generated HTML document in the Docdirectory directory):

1. If you want to generate a package: javadoc-d docdirectory-version-author nameofpackage

2. If you want to generate multiple packages: javadoc-d docdirectory-version-author nameOfPackage1 nameOfPackage2 .....

3. If the file is in the default package: javadoc-d docdirectory-version-author *.java

If you omit-D docdirectory then the resulting HTML document will be saved in the current directory, which can be confusing and not advocated.

-version-author indicates that version information and author information are required to be included in the documentation. Nameofpackage represents the package name in which the Java class resides.

Working with document annotations (Javadoc)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.