java--Custom Annotations

Source: Internet
Author: User

Java annotations generally fall into three main categories:

1. Marking annotations

2. Tag meta annotations

3. General Notes

where 1. Tag annotations include

One override: Overriding methods in the superclass

Two Deprecated: Discarded classes

Three suppresswarings: Suppresses the compiler from issuing specific warnings

2. Tag meta annotations

A Generate: Identifies the source code generated by the computer

3. General Notes

A @Inherited tag inheritance relationship
Goal of the two @Target labeling
Three @Documented//Mark Generation Javadoc
Four @Retention (retentionpolicy.runtime)//lifetime of annotations

Instance:

1 Importjava.lang.annotation.Documented;2 Importjava.lang.annotation.Retention;3 ImportJava.lang.annotation.RetentionPolicy;4 5 //@Inherited Tag Inheritance relationships6 //@Target The target of the callout7@Documented//tag Generation Javadoc8@Retention (Retentionpolicy.runtime)//lifetime of the annotations9  Public@InterfacePerson {Ten String name (); One String Age (); A}

Called, where reflection is used

1 Importjava.lang.annotation.Documented;2 Importjava.lang.annotation.Retention;3 ImportJava.lang.annotation.RetentionPolicy;4 5 //@Inherited Tag Inheritance relationships6 //@Target The target of the callout7@Documented//tag Generation Javadoc8@Retention (Retentionpolicy.runtime)//lifetime of the annotations9  Public@InterfacePerson {Ten String name (); One String Age (); A}

java--Custom Annotations

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.