Home>Article>Java> What are the three forms of java comments?

What are the three forms of java comments?

青灯夜游
青灯夜游 Original
2023-01-05 14:50:53 17124browse

Three forms of java comments: 1. Single-line comments, marked with double slashes "//", can only comment one line of content, and are used in places with little comment information. The syntax is "//"and" ". 2. Multi-line comments, included between "/*Annotation content*/", can comment on many lines of content, the syntax is "/*

"and"
*/". 3. Document comments, included between "/**"and"*/", can also comment on multiple lines of content. They are generally used on classes, methods and variables to describe their functions. The syntax is "/**", the next one will also be scanned"*/".

What are the three forms of java comments?

The operating environment of this tutorial: windows7 system, java8 version, DELL G3 computer.

Comments are descriptions of the programming language, which facilitate communication between developers and users and facilitate understanding of the program. Comments are not programming statements and therefore are ignored by the compiler.Java supports three comment methods:

1) Single-line comment

Identified by double slashes "

//

", only one line of content can be commented, and it is used in places with little information content. Open Eclipse and use single-line comments in the Java code, as shown in Figure 1.What are the three forms of java comments?

Figure 1 Single-line comment

2) Multi-line comment

is included in "/*"and"

*/

", many lines of content can be commented. For better readability, generally no comment information is written in the first and last lines (this is also more beautiful and beautiful), as shown in Figure 2.

Note: Multi-line comments can nest single-line comments, but multi-line comments and document comments cannot be nested.What are the three forms of java comments?

Figure 2 Multi-line comments

3) Documentation comments

are included in "/**## "#&*/

" can also be used to comment multiple lines of content. It is generally used on classes, methods and variables to describe their functions. After commenting, placing the mouse on the class and variable will automatically display the content of our comment, as shown in Figure 3.

Note: Document comments can nest single-line comments, but multi-line comments and document comments cannot be nested. Generally, no comment information is written in the first and last lines.

What are the three forms of java comments?

Figure 3 Documentation comments

Documentation comments can use the Javadoc command to generate documents from the content in the documentation comments and output them to HTML files to facilitate recording program information. You can also include one or more @ tags, each starting on a new line.

In Java, a line of comments is identified by double slashes "//"; multi-line comments are included between "/*&*/"; documentation comments are included between " /**&*/"between.

When the compiler executes to "//", it will ignore all text after the line "//"; when it executes to "/*", it will scan the next "*/" and ignore "/* &*/"; when executing to "/**&*/" and ignore any text content between "/**&*/".

For more programming-related knowledge, please visit:Programming Teaching

! ! ###

The above is the detailed content of What are the three forms of java comments?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn