Java中的这些多行注释有什么区别吗?

Is there any difference between these multi-line comments in Java?

我只是想知道这些类型的评论之间是否有任何区别。

/* 
...    
Content of the comment
...    
*/

/* 
* ...    
* Content of the comment
* ...    
*/

不,没有区别。这纯粹是一种风格决定。

没有任何区别。只是方式不同。

我更喜欢第一种形式:

/*

something

*/

特别是如果注释掉的部分是代码并且我正在尝试一些东西。由于显而易见的原因,每行开头的额外星号会导致这种情况令人头疼。

现代 IDE 还支持同时注释多行的快捷方式。例如在 Eclipse 中,您可以 select 几行并按 CTRL + / 将它们注释掉。评论的形式如下:

// line1
// line2
// ...

没有区别,但是这个语法

/* 
* ...    
* Content of the comment
* ...    
*/

更适合生成JavaDoc

来自http://javadude.com/articles/comments.html

Documentation comments should (at very least) be used in front of every public class, interface, method and class/instance variable in your source code. This allows someone to run javadoc against the code and generate a simple document that lists the public entities and a brief description of each. You may also use documentation comments in front on non-public methods, and use a javadoc option to generate documentation for them. Using documentation comments on non-public entities is not as important as publics (the interface isn't exposed...) but if you're commenting the code anyway you might as well write those comments as documentation comments.

不,这没什么区别。

旁注(为了完整起见) 以下举例有区别

/* 
* ...    
* Content of the comment
* ...    
*/

/**
* ...    
* Content of the comment
* ...    
*/

第二个表示javadoc注释(注释第一行的**)。在那里你可以使用不同的标签来增强你的javadoc。

没有区别

作为开发人员,无论我们正在编写什么代码,我们都需要在特定的 code.for 文档目的之上制作一个小文档,我们将根据我们的选择使用这些注释,我们可以使用任何我们想要的.