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 工具生成原始碼文件。
示例
/**
* @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
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP