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

朱利钦:

我注意到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.
*
*
*/

以下是维基百科有关Javadoc 的摘录

Javadoc注释通过标准的多行注释标记/ *和* /从代码中取消。开头的标记(称为开始注释定界符)带有一个额外的星号,如/ **所示。

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
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章