Name
Annotation
Synopsis
A type declared with the
@interface
syntax is an annotation type that
implicitly extends this interface. Note that the
Annotation
interface is not itself an annotation
type. Furthermore, if you define an interface
(rather than an @interface
) that explicitly
extends Annotation
, the result is not an
annotation type either. The only way to define an annotation type is
with an @interface
definition. When an annotation
is queried with the
java.lang.reflect.AnnotatedElement
API, the object
returned implements this interface as well as the interface defined
by the specific annotation type.
This interface defines the annotationType(
)
method, which returns the
Class
of the annotation type for any annotation
object. It also includes the equals(
)
and hashCode( )
methods of
Object
to require an implementation to compare
annotations by the values of their members rather than simply by
using = =
. Finally, Annotation
also overrides the toString( )
method to require
implementations to provide some meaningful string representation of
an annotation. The format of the returned string is not specified,
but you can expect implementations to produce a string using a syntax
similar to that used to encode annotations in Java source code.
public interface Annotation { // Public Instance Methods Class<? extends java.lang.annotation.Annotation> annotationType( ); boolean equals(Object obj); int hashCode( ); String toString( ); }
Implementations
Deprecated
, Override
,
SuppressWarnings ...
Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.