[英]Difference between /* and /**
我发现,在日食中,
/*
* Hello world, this is green.
*
*/
评论将是绿色的。 然而,
/**
* Hello moon, this is blue.
*
*/
如果我使用/**,它会变成蓝色。 所以为什么? 有什么区别吗?
/*
开始一个常规的多行注释, /**
开始一个支持javadoc
工具的多行注释,它从您的注释生成 HTML 文档。
这是文档中的一个示例:
/**
* Returns an Image object that can then be painted on the screen.
* The url argument must specify an absolute {@link URL}. The name
* argument is a specifier that is relative to the url argument.
* <p>
* This method always returns immediately, whether or not the
* image exists. When this applet attempts to draw the image on
* the screen, the data will be loaded. The graphics primitives
* that draw the image will incrementally paint on the screen.
*
* @param url an absolute URL giving the base location of the image
* @param name the location of the image, relative to the url argument
* @return the image at the specified URL
* @see Image
*/
public Image getImage(URL url, String name) {
try {
return getImage(new URL(url, name));
} catch (MalformedURLException e) {
return null;
}
}
Java API 规范本身就是一个通过javadoc
生成的 HTML 文档示例。
以/*
开头的注释是正常的代码注释。 这些通常用在代码行的顶部来描述逻辑。
以/**
开头的注释用于 javadoc。 这些用于方法和类之上
虽然/**
注释起始符是针对 javadoc 的,但从技术上讲,从编译器的角度来看,它们实际上是相同的。 评论是评论是评论。 这里的重要部分是/**
是/*
加上一个额外的星号。
/* text */
:编译器忽略从/*
到*/
/** documentation */
:这表示文档注释(简称文档注释)。 编译器会忽略这种注释,就像忽略使用 /* 和 */ 的注释一样。 JDK javadoc 工具在准备自动生成的文档时使用文档注释。 有关 javadoc 的更多信息,请参阅 Java 工具文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.