gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:14:24 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com