Multi-line comments and Single-line comments in Java

Source: Internet
Author: User
Tags closing tag comments

There are two types of annotations in Java. The first is a traditional, C-style annotation, inherited from C + +. These comments start with a "/*", followed by a comment, and can span multiple lines, ending with a "* *". Note that many programmers start with a "*" in each row of a continuous annotation, so you can often see things like the following:

* * This is
* A note,
* It spans multiple lines
*/

But keep in mind that everything between/* and * * is ignored when compiling, so the above comment is no different from the following note:

/* This is a note,
It spans multiple lines.

The second type of annotation also originated in C + +. This annotation is called a "single-line comment" and begins with a "//" to indicate that all content in the line is a comment. This type of annotation is more common because it is easier to write. There is no need to look for "/" on the keyboard, and then look for "*" (just press the same key two times) and do not have to add a closing tag at the end of the comment. Here is an example of this type of annotation:

This is a single-line 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.