[英]Java: comments /* * * */
Quick question, it there a difference between:快速提问,它之间有区别:
/* This is first line of comments
This is the second line
And this will be the last line
*/
and:和:
/*This is first line of comments
*This is the second line
*And this will be the last line
*/
in java language?用java语言?
The source I learned from teaches the second form, but I found out the fist one works too.我学习的来源教了第二种形式,但我发现第一种也有效。
There is no difference at all as far as the compiler is concerned.就编译器而言,根本没有区别。 It's just a matter of what looks pretty and what documentation generators rely upon.
这只是外观漂亮以及文档生成器所依赖的问题。 That last point is surprisingly important: particularly in Java.
最后一点非常重要:尤其是在 Java 中。 (Javadoc relies upon well-defined comment forms.)
/*
defines the start of a comment, and you'll stay in "comment mode" until the first */
is reached. (Javadoc 依赖于定义良好的注释形式。)
/*
定义了注释的开始,您将保持“注释模式”直到到达第一个*/
。
So further /*
are allowed within a comment block (but they don't nest so you still only need one closing */
).因此,在注释块中允许进一步使用
/*
(但它们不嵌套,因此您仍然只需要一个关闭*/
)。 And the single line comment //
within a comment block is benign: //*/
will close a comment block.注释块中的单行注释
//
是良性的: //*/
将关闭注释块。
There is difference between之间有区别
/* This is first line of comments
This is the second line
And this will be the last line
*/
And和
/**
* This is javadoc
* Refer to <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/javadoc/">javadoc</a> for details
*/
/* 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.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.