Java FAQ _03 Basic Syntax (018) _ What is the comment

Source: Internet
Author: User

Click to enter _ more _java thousand ask

1. What is a note?

Comments in Java, like comments in other programming languages, are not compiled, but are simply explanations of the code in the source code.
Adding code annotations can improve the readability of the source code, making the Java program clear and easy to distinguish between lines of code and comments. In addition, content annotations such as author, add/Modify time, program version, and code functionality are often added at the beginning of a class, method, or code snippet to facilitate later maintenance and programmer communication. (Of course, for good code, not to write comments can also be very readable)

2, note how to use

For Java annotations, we can add anywhere in the code, with the following three main syntax:

    1. //
      A line of comments that is generally used to explain the meaning of a variable or a line of code.

    2. /* ...... */
      Comment on several lines, and comment on multiple lines as follows:

/* ......  * ......  * ......   */

Generally used to describe a piece of code writing ideas, implementation procedures or considerations.

    1. /* * ...... */
      Document comments, which are written in a multi-line notation, differ from the Javadoc tools provided by the JDK to generate code documents (such as HTML formats) to facilitate the formation of development documentation. It is not only possible to annotate multiple lines, but also to add some tags for generating documents to use, as follows:
/*** .........* .........* @author sunjie at 2016年6月18日* @version 1.0.0* @param name*????名称* @param sex *????性别* @return boolean??*????是否成功*/

It is important to note that Javadoc only extracts/* * ..... * * This type of comment.
Learn Javadoc look here: [Javadoc is what][2]

Java FAQ _03 Basic Syntax (018) _ What is the comment

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.