我应该使用 /* */ 或 /** */ 作为 java 文件顶部的版权吗?
每个java文件中都有版权注释,但我不知道该使用哪一个:/* */
还是/** */
?
/*
* Copyright ...
*/
import java.util.*
...
或者
/**
* Copyright ...
*/
import java.util.*
....
There is a copyright comment in each java file, but I don't know which one should I use: /* */
or /** */
?
/*
* Copyright ...
*/
import java.util.*
...
or
/**
* Copyright ...
*/
import java.util.*
....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这个相当旧的(大约 1999 年)Sun 编码约定 文件建议
/* */
。更具体地说,它建议您的类/接口文件采用以下布局:
开始注释
<前><代码>/*
* 类名
* 版本信息
* 日期
* 版权声明
*/
package
和import
语句例子:
This rather old (circa 1999) Sun coding conventions document suggests
/* */
.More specifically, it suggests the following layout for your class/interface file(s):
Beginning comments
package
andimport
statementsExample:
如果
/** ... */
注释直接位于要记录的任何声明之前,Javadoc 只会收集它们。package
(package-info.java 中除外)和import
声明无论如何都没有记录,因此 Javadoc 不会以任何一种方式查看注释。由于这对于 Javadoc 来说并不重要,因此您也可以使用“较轻”的
/* ... */
版本。Javadoc will only gather
/** ... */
comments if they are directly before any declaration to be documented.package
(other than in package-info.java) andimport
declarations are not documented anyway, so Javadoc will not look at the comment in either way.As it doesn't matter for Javadoc, you can as well use the "less heavy"
/* ... */
version.如果您使用
/** */
文档工具会抓住它,所以您最好使用它:)If you use
/** */
documenting tools will grab it so you're better off using it :)我刚刚看了一些开源java项目,发现它们都使用
/* */
I just read some open source java projects, found they all use
/* */