Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Exactly Does @param Work - Java

Tags:

java

param

How does the annotation @param work?

If I had something like this:

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

How would the @param affect the testNumber? Does it even affect the testNumber?

Thanks. Let me know if I used it wrong.

like image 662
user2228462 Avatar asked Apr 22 '13 01:04

user2228462


People also ask

What is the use of @param annotation?

In Spring MVC, the @RequestParam annotation is used to read the form data and bind it automatically to the parameter present in the provided method. So, it ignores the requirement of HttpServletRequest object to read the provided data.

What is @param annotation in Java?

In Java, annotations are the tags that represent the metadata, which is attached with a class, interface, methods, etc., to indicate some special type of additional information that can be used by JVM and Java compiler. The @param annotation is a special format comment used by the javadoc that generates documentation.

What does @param and @return do?

@param describes a parameter and @return describes the return value.


2 Answers

@param is a special format comment used by javadoc to generate documentation. it is used to denote a description of the parameter (or parameters) a method can receive. there's also @return and @see used to describe return values and related information, respectively:

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

has, among other things, this:

/**  * 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) { 
like image 64
rmalchow Avatar answered Sep 27 '22 00:09

rmalchow


@param won't affect the number. It's just for making javadocs.

More on javadoc: http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html

like image 34
corgichu Avatar answered Sep 23 '22 00:09

corgichu