java -/* ...*/和/** ... */有什么区别

标签 java android eclipse

我注意到 Eclipse 打印不同格式的评论:

/* Eclipse prints it in green 
*/

或者如果你写:

/** Eclipse prints it in blue
*/

这两种评论有什么区别?

最佳答案

/* 
* It is multi-line comment in Java
*
*/

/** 
* It is a Javadoc. Can be found above methods and Class definitions.
*
*
*/

这是 Wikipedia 的摘录关于 Javadoc:

A Javadoc comment is set off from code by standard multi-line comment tags /* and */. The opening tag (called begin-comment delimiter), has an extra asterisk, as in /**.

The first paragraph is a description of the method documented.
Following the description are a varying number of descriptive tags, signifying:
    The parameters of the method (@param)
    What the method returns (@return)
    Any exceptions the method may throw (@throws)
    Other less-common tags such as @see (a "see also" tag)

类级别的 Javadoc 示例:

/**
 * @author      Firstname Lastname <address @ example.com>
 * @version     1.6                 (current version number of program)
 * @since       2010-03-31          (the version of the package this class was first added to)
 */
public class Test {
    // class body
}

方法级 Javadoc 示例:

/**
 * Short one line description.                           
 * <p>
 * Longer description. If there were any, it would be    
 * here.
 * <p>
 * And even more explanations to follow in consecutive
 * paragraphs separated by HTML paragraph breaks.
 *
 * @param  variable Description text text text.          
 * @return Description text text text.
 */
public int methodName (...) {
    // method body with a return statement
}

关于java -/* ...*/和/** ... */有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27091506/

相关文章:

java - TreeItem.branchExpandedEvent() 中的 NullPointerException 尝试 getGraphic

java - 使用 Android 收听广播

java - 巨大的 XML 文件到文本文件

android - 垂直和水平居中 TextView 的内容 - LinearLayout

android - Android 上的 Python 3 使用 TerminalIDE

android - fragment 没有创建 View

java - 是否有为 Java EE 容器定义 JDBC 数据源的标准方法?

java - Eclipse 不会在设备上运行 Android 应用程序

java - 我正在尝试在 Eclipse 中导出一个可运行的 jar,但我需要它包含一些运行我的程序所需的其他文件

android - 如何检测内存泄漏