@param究竟是如何工作的 - Java

2022-09-01 05:49:25

注释如何工作?@param

如果我有这样的东西:

/* 
*@param testNumber;
*/

int testNumber = 5;
if (testNumber < 6) {
   //Something
}

这将如何影响测试编号?它甚至会影响测试编号吗?@param

谢谢。如果我用错了,请告诉我。


答案 1

@paramjavadoc 用来生成文档的特殊格式注释。它用于表示方法可以接收的参数(或多个参数)的描述。还有并分别用于描述返回值和相关信息:@return@see

http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html#format

除其他事项外,还有:

/**
 * 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) {

答案 2

@param不会影响数字。它只是为了制作javadocs。

有关javadoc的更多信息: http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html


推荐