Comment: It is the explanation of the meaning of the code
There is a lot of code and it is easy to forget, please add annotations and explanations-> What developers and maintainers see, not what the platform computer sees
In Java, there are three ways to mark comments: /Comments cannot be nested. In other words, you cannot simply use /* and & & & & #& & (Recommended learning: java course)
//Single-line comments
System.out.println("welcome CSDN");//打印输出welcome CSDN
Multi-line comments:/* &*/
public class HelloWorld{ /* *main方法程序的入口 */ public static void main(String[]args){ } }
Documentation comment: /**&*/
package com.bdqn.output; /** *@version 1.1 *@author 王靖文 */ public class HelloWorld{ public static void main(String[]args){ System.out.println("welcome CSDN"); } }
Warning: In Java, /** &*/ is enclosed as a comment because the code itself may also contain a */.
The above is the detailed content of How to comment in java. For more information, please follow other related articles on the PHP Chinese website!