Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of @param annotation in Java code?

/**
*@param context
*@param attrs
*/
Public DotView(Context context, Attribute attrs) {
     super(context, attrs);
     setFocusAbleInTouch(true);
}

Does the @param serve any purpose. I saw this code in an Android programming book, but the author didn't explain what the @param meant. I know it is inside a double line comment so I am assuming @param doesn't do anything to the outcome and it is there for readability. Am I right or wrong?

like image 703
JavaNoob Avatar asked May 22 '13 00:05

JavaNoob


People also ask

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 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 used for in Java?

@param will not affect testNumber.It is a Javadoc comment - i.e used for generating documentation . You can put a Javadoc 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.

What is @param and @return in Java?

@param describes a parameter and @return describes the return value. (There are several other useful tags.) Remember that Javadoc generates documentation from your code, not just from your comments.


1 Answers

Does the @param serve any purpose

It is part of the JavaDocs documentation system.

like image 180
CommonsWare Avatar answered Oct 15 '22 13:10

CommonsWare