Java:评论/* * * */

Java: comments /* * * */

快速提问,两者之间有区别:

/* This is first line of comments
This is the second line
And this will be the last line
*/

和:

 /*This is first line of comments
*This is the second line
*And this will be the last line 
*/

使用 java 语言?

我学习的来源教的是第二种形式,但我发现第一种形式也有效。

就编译器而言,完全没有区别。这只是什么看起来漂亮以及文档生成器依赖什么的问题。 最后一点非常重要:特别是在 Java. 中(Javadoc 依赖于定义明确的注释表单。)/* 定义了发表评论,您将停留在 "comment mode" 直到到达第一个 */

因此,评论块中还允许 /*(但它们不会嵌套,因此您仍然只需要一个结束 */)。评论块中的单行评论 // 是良性的://*/ 将关闭评论块。

/* text.... */

The compiler ignores everything from /* to */.

/** documentation */

This is a documentation comment and in general its called doc comment.
The JDK javadoc tool uses doc comments when preparing automatically generated documentation.

有区别

/* This is first line of comments
This is the second line
And this will be the last line
*/

/**
 * This is javadoc
 * Refer to <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/javadoc/">javadoc</a> for details
 */