GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing docs.oracle.com — Predefined Annotation Types (The Java™ Tutorials > Learning the Java Language > Annotations) Documentation
The Java™ Tutorials
Hide TOC
Trail: Learning the Java Language
Lesson: Annotations The Java Tutorials have been written for JDK 8. Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available. Predefined Annotation TypesA set of annotation types are predefined in the Java SE API. Some annotation types are used by the Java compiler, and some apply to other annotations. Annotation Types Used by the Java LanguageThe predefined annotation types defined in @Deprecated
// Javadoc comment follows
/**
* @deprecated
* explanation of why it was deprecated
*/
@Deprecated
static void deprecatedMethod() { }
}
@Override
// mark method as a superclass method
// that has been overridden
@Override
int overriddenMethod() { }
While it is not required to use this annotation when overriding a method, it helps to prevent errors. If a method marked with @SuppressWarnings
// use a deprecated method and tell
// compiler not to generate a warning
@SuppressWarnings("deprecation")
void useDeprecatedMethod() {
// deprecation warning
// - suppressed
objectOne.deprecatedMethod();
}
Every compiler warning belongs to a category. The Java Language Specification lists two categories: @SuppressWarnings({"unchecked", "deprecation"})
@SafeVarargs
@FunctionalInterface
Annotations That Apply to Other AnnotationsAnnotations that apply to other annotations are called meta-annotations. There are several meta-annotation types defined in @Retention
@Documented
@Target
@Inherited
@Repeatable
About Oracle | Contact Us | Legal Notices | Terms of Use | Your Privacy Rights Copyright © 1995, 2024 Oracle and/or its affiliates. All rights reserved.
Previous page: Declaring an Annotation Type
Next page: Type Annotations and Pluggable Type Systems |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |