Current location - Education and Training Encyclopedia - Education and training - How does Java make single-line comments and multi-line comments?
How does Java make single-line comments and multi-line comments?
(1) Single-line comment: starts with "//",followed by the content to be added. As shown below://Define the variable A int A =10; //Define the variable b int b = 20 In the above statement, the comments will be directly skipped during compilation, and only two sentences will be compiled, int a = 10 and int b = 20. It can be seen that notes only play an explanatory role.

(2) Multi-line comments: start with "/*" and end with "*/". Suppose when you want to explain the function of the code you wrote. There is a lot to explain. If they are all in the same row, they will look ugly. Therefore, you will usually write multiple lines, as follows//Description//Description//Description. The above is to annotate four lines with four single-line notes. However, if there is a 10 line instruction, it will be very troublesome to press ten "//",and then you can use multiple lines of comments. The above can be changed to:/* explain explain */You can also do this/* explain explain */

(3) Document comments: start with "/* *" and end with "*/". Document annotation is mainly used to generate documents.