Dark Horse programmer-Explanation

Source: Internet
Author: User

Metadatabase: the comment.

Metadata: data.

Different annotations will play a role in a period of no need. retentionpolicy. Source, retentionpolicy. Class, retentionpolicy. runtime are the source files in Java, class files, and bytecode in memory.

Override and suppresswarnings correspond to source, and deprecated corresponds to runtime,

In addition to the basic three types, there are:

@ Target meta Annotation

@ Target (elementtype. menthod) the specified annotation can only be used in methods.

@ Target ({elementtype. menthod, elementtype. Type}) the specified annotation can be used on both methods, subclass, interface, or enumeration.

Here elementtype is an enumeration class (★Generally, enumeration, interfaces, and comments are very similar to classes, but they are not classes but only types)

@ Retetion meta Annotation

@ Retention (retentionpolicy. runtime) This specifies the period in which the specified comment can be used.

In addition, we can customize annotations and create new annotations in myeclipse.

Annotation Note: Anno. Java

 

Use the annotated person class and assign a value to the annotation: person. Java

 

 

Define an enumeration class myname. Java

Demo1 class of the person class called by application reflection: demo1.java

 

Inherit the demo2: demo2.java subclass of the demo1 class

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.