我发现,在eclipse中,
/*
* Hello world, this is green.
*
*/
评论将为绿色。然而,
/**
* Hello moon, this is blue.
*
*/
如果我使用/**,它会变成蓝色。 所以为什么?有什么区别吗?
最佳答案
/*
开始一个常规的多行注释,/**
开始一个支持javadoc
tool 的多行注释。 ,它会根据您的评论生成 HTML 文档。
这是一个例子 from the documentation :
/**
* 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;
}
}
The Java API specification itself是通过 javadoc
生成的 HTML 文档的示例。
关于java -/* 和/** 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23357887/