Java 中 /* */ 和 /** */ 注释有什么区别?
多行注释 (/* */) 用于对源码中的多行进行注释。
示例
public class CommentsExample { /* Following is the main method here, We create a variable named num. And, print its value * */ public static void main(String args[]) { //Declaring a variable named num int num = 1; //Printing the value of the variable num System.out.println("value if the variable num: "+num); } }
输出
value if the variable num: 1
文档注释 (/** */) 用于使用 Javadoc 工具生成源码文档。
Learn Java in-depth with real-world projects through our Java certification course. Enroll and become a certified expert to boost your career.
示例
/** * @author Tutorialspoint */ public class CommentsExample { public static void main(String args[]) { int num = 1; System.out.println("value if the variable num: "+num); } }
输出
value if the variable num: 1
你可以使用 Javadoc 命令生成上述类的 Java 文档:-
C:\Sample>javadoc CommentsExample.java
广告