Brief discussion on the function of @param annotation and @see annotation in Java _java

Source: Internet
Author: User

@ param
the @ param tag can archive a single parameter of a method or constructor, or an archive class, interface, and the type parameters of a generic method. When using the @ param tag, we should use a label for each parameter of the method. The first word of each paragraph is treated as a parameter name, and the remainder is treated as a description of it:

@param max The maximum number of words to read.

When archiving type parameters, we should add < to both sides of the type parameter name:

@param an e element type of this List

However, type parameters usually do not require an explicit document, because they are very significant.

@
The @ can tag creates cross-references that link to other Javadoc documents. We can name any identifiers after the tag, although we have to qualify them adequately. For example, you can usually name a member of a class by using its simple name, but if that member is an overloaded method, we must specify the overloaded version of the method by enumerating the types of the arguments. We can use unqualified names to specify the interfaces or classes within the current package, but you must use the fully qualified name to specify the type in the other package. We can specify a member of a type by using # before the member name. The following are all valid @-to-tag formats:

@see #getName

@see Attr

@see com.magic.attr.Attr

@see com.magic.attr.deck#deck-size @see

com.magic . attr. Attr#getname

@see com.magic.attr.attr#attr (String)

@see com.magic.attr.attr#attr (string,object)

@see Com.magic.attr

@see Attribute specification

@see "The Java Developer ' s Almanac"

The first form refers to a method named GetName, which is located in the same class or interface as the document annotation itself, or in a enclosing class or bounding interface, and such syntax can also be applied to constructors and fields. The second form refers to classes in the current package or in a guide package. The third form refers to a class with a fully qualified name.

The latter 4 forms of @see refer to members, where the first two are in the form of fields (Deck-siz days and Methods (GetName). We can use the method name directly, because only one getname method is defined in the Attr class. The latter two forms refer to the constructor of the Attr class, where one constructor accepts a string argument and the other constructor accepts strings and objects. When a constructor or method has overloaded versions, we must specify the arguments of the overloaded version that you want to reference.

The next @see form leads the reader to a specific package: Com.magic.attro

The last two forms allow us to refer to other documents. The previous one used to define the link, and the latter used quotes to enclose the document name. We can use these two forms to direct readers to other documents, such as a complete manual.

The @ visible form, which is named for the language entity (all forms except the last two forms above), can follow a label (label) at the back of the entity. In the resulting document, the name of the label will replace the name of the entity. For example:

@ #getNameAttribute Names

A link to the GetName document is created, but the text displayed is "Attribute Names" instead of "GetName". Usually we should use the real names of the members, but the features shown here are occasionally useful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.