Comments for Java

Source: Internet
Author: User

    1. Single-line Comment
    2. Multi-line comments
    3. Document comments

single-line comment : Precede the content that needs to be commented with a double slash (//)

Multiline Comment: include the content you want to comment with */* */

Document Comments :/** */Documentation comments are used to generate API documentation (generated using Javadoc), and API documentation is primarily used to describe the functions of classes, member variables, methods. Therefore, the Javadoc tool only handles annotations before classes, interfaces, inner classes, member variables, methods, and constructors. Also, the default method of private modification or member variable does not generate a comment document unless the-private parameter is added when using the Javadoc tool.

Basic usage of the Javadoc tool:

Javadoc a bunch of parameters Java source files (or packages)

The parameters that can be taken are:

-D <directory> Specifies that the generated API documents will be placed in that directory

-windowtitle <text> Setting the browser window title of the API document

-author display author in the document (requires a note indicating author)

-version display version in the document

-CHARSET Specifies the encoding of the API documentation, such as-charest Utf-8

Additional parameters use Javadoc--help (Linux system) to view

Some of the tags you can use when writing a document comment:

@author author

@version version

Parameter descriptions for @param methods

The return value of the @return method

@see See, specifying reference content

@exception the type of exception thrown

@throws is the same as exception.

You can create a package.html in each package to describe the package, and then extract comments from all classes in the package directly into the API document by Javadoc a bunch of parameter packs

Comments for Java

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.