@param究竟如何工作 – Java

@param注释如何工作?

如果我有这样的事情:

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

@param如何影响testNumber? 它甚至会影响testNumber吗?

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

@param不会影响号码。 我相信这只是为了制作javadoc。

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

@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. * 

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

@param不会影响testNumber。它是一个Javadoc注释 – 即用于生成文档。 您可以在类,字段,方法,构造函数或接口(如@return @param@return之前立即放置Javadoc注释。 通常以’ @ ‘开头,并且必须是第一件事。

使用@param的优点是: – 通过创建包含属性和一些自定义Javadoc标记的简单Java类,您可以将这些类用作代码生成的简单元数据描述。

  /* *@param testNumber *@return integer */ public int main testNumberIsValid(int testNumber){ if (testNumber < 6) { //Something } } 

每当在代码中重用testNumberIsValid方法时,IDE将显示方法接受的参数并返回方法的类型。

这基本上是一个评论。 众所周知,从事同一项目的许多人必须了解代码更改。 我们在程序中做了一些关于参数的注释。