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.
It is basically a comment. As we know, a number of people working on the same project must have knowledge about the code changes. We are making some notes in the program about the parameters.
@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
@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:
@param
will not affect testNumber.It is aJavadoc
comment - i.e used for generating documentation . You can put aJavadoc
comment immediately before a class, field, method, constructor, or interface such as@param
,@return
. Generally begins with '@' and must be the first thing on the line.The Advantage of using
@param
is :- By creating simple Java classes that contain attributes and some custom Javadoc tags, you allow those classes to serve as a simple metadata description for code generation.Whenever in your code if you reuse testNumberIsValid method, IDE will show you the parameters the method accepts and return type of the method.