/*和/**之间的区别

Gon*_*han 11 java eclipse

我发现,在日食中,

/*
 * Hello world, this is green.
 *
 */
Run Code Online (Sandbox Code Playgroud)

评论将是绿色的.然而,

/**
 * Hello moon, this is blue.
 *
 */
Run Code Online (Sandbox Code Playgroud)

如果我使用/**,它将变为蓝色.所以为什么?有什么区别?

jno*_*ovo 9

/*启动常规多行注释时,/**启动支持该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;
    }
}
Run Code Online (Sandbox Code Playgroud)

Java API规范本身就是通过生成的HTML文档的示例javadoc.