Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/java/lang/annotation/Annotation#pubmethods)

# Annotation


`
public


interface
Annotation
`


`


`

|---|
| java.lang.annotation.Annotation |

|---|
| Known indirect subclasses [CriticalNative](https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative), [Deprecated](https://developer.android.com/reference/java/lang/Deprecated), [Documented](https://developer.android.com/reference/java/lang/annotation/Documented), [FastNative](https://developer.android.com/reference/dalvik/annotation/optimization/FastNative), [FlakyTest](https://developer.android.com/reference/android/test/FlakyTest), [FunctionalInterface](https://developer.android.com/reference/java/lang/FunctionalInterface), [Generated](https://developer.android.com/reference/javax/annotation/processing/Generated), [Inherited](https://developer.android.com/reference/java/lang/annotation/Inherited), [JavascriptInterface](https://developer.android.com/reference/android/webkit/JavascriptInterface), [LargeTest](https://developer.android.com/reference/android/test/suitebuilder/annotation/LargeTest), [MediumTest](https://developer.android.com/reference/android/test/suitebuilder/annotation/MediumTest), [Native](https://developer.android.com/reference/java/lang/annotation/Native), [Override](https://developer.android.com/reference/java/lang/Override), [RemoteViews.RemoteView](https://developer.android.com/reference/android/widget/RemoteViews.RemoteView), [Repeatable](https://developer.android.com/reference/java/lang/annotation/Repeatable), and 18 others. |---|---| | [CriticalNative](https://developer.android.com/reference/dalvik/annotation/optimization/CriticalNative) | An ART runtime built-in optimization for `native` methods to speed up JNI transitions: Methods that are annotated with @`CriticalNative` use the fastest available JNI transitions from managed code to the native code and back. | | [Deprecated](https://developer.android.com/reference/java/lang/Deprecated) | A program element annotated `@Deprecated` is one that programmers are discouraged from using. | | [Documented](https://developer.android.com/reference/java/lang/annotation/Documented) | If the annotation `@Documented` is present on the declaration of an annotation interface *A*, then any `@A` annotation on an element is considered part of the element's public contract. | | [FastNative](https://developer.android.com/reference/dalvik/annotation/optimization/FastNative) | An ART runtime built-in optimization for `native` methods to speed up JNI transitions: Compared to normal `native` methods, `native` methods that are annotated with @`FastNative` use faster JNI transitions from managed code to the native code and back. | | [FlakyTest](https://developer.android.com/reference/android/test/FlakyTest) | *This @interface was deprecated in API level 24. Use [FlakyTest](https://developer.android.com/reference/android/support/test/filters/FlakyTest) instead. New tests should be written using the [Android Testing Support Library](https://developer.android.com/tools/testing-support-library).* | | [FunctionalInterface](https://developer.android.com/reference/java/lang/FunctionalInterface) | An informative annotation type used to indicate that an interface type declaration is intended to be a *functional interface* as defined by the Java Language Specification. | | [Generated](https://developer.android.com/reference/javax/annotation/processing/Generated) |   | | [Inherited](https://developer.android.com/reference/java/lang/annotation/Inherited) | Indicates that an annotation interface is automatically inherited. | | [JavascriptInterface](https://developer.android.com/reference/android/webkit/JavascriptInterface) | Annotation that allows exposing methods to JavaScript. | | [LargeTest](https://developer.android.com/reference/android/test/suitebuilder/annotation/LargeTest) | *This @interface was deprecated in API level 24. Use [LargeTest](https://developer.android.com/reference/android/support/test/filters/LargeTest) instead. New tests should be written using the [Android Testing Support Library](https://developer.android.com/tools/testing-support-library).* | | [MediumTest](https://developer.android.com/reference/android/test/suitebuilder/annotation/MediumTest) | *This @interface was deprecated in API level 24. Use [MediumTest](https://developer.android.com/reference/android/support/test/filters/MediumTest) instead. New tests should be written using the [Android Testing Support Library](https://developer.android.com/tools/testing-support-library).* | | [Native](https://developer.android.com/reference/java/lang/annotation/Native) | Indicates that a field defining a constant value may be referenced from native code. | | [Override](https://developer.android.com/reference/java/lang/Override) | Indicates that a method declaration is intended to override a method declaration in a supertype. | | [RemoteViews.RemoteView](https://developer.android.com/reference/android/widget/RemoteViews.RemoteView) | This annotation indicates that a subclass of View is allowed to be used with the `https://developer.android.com/reference/android/widget/RemoteViews` mechanism. | | [Repeatable](https://developer.android.com/reference/java/lang/annotation/Repeatable) | The annotation interface `java.lang.annotation.Repeatable` is used to indicate that the annotation interface whose declaration it (meta-)annotates is *repeatable*. | | [RepetitiveTest](https://developer.android.com/reference/android/test/RepetitiveTest) | *This @interface was deprecated in API level 29. New tests should be written using the [Android Testing Support Library](https://developer.android.com/tools/testing-support-library).* | | [Retention](https://developer.android.com/reference/java/lang/annotation/Retention) | Indicates how long annotations with the annotated interface are to be retained. | | [SafeVarargs](https://developer.android.com/reference/java/lang/SafeVarargs) | A programmer assertion that the body of the annotated method or constructor does not perform potentially unsafe operations on its varargs parameter. | | [Serial](https://developer.android.com/reference/java/io/Serial) | Indicates that an annotated field or method is part of the [serialization mechanism](https://developer.android.com/reference/java/io/Serializable) defined by the Java Object Serialization Specification. | | [SmallTest](https://developer.android.com/reference/android/test/suitebuilder/annotation/SmallTest) | *This @interface was deprecated in API level 24. Use [SmallTest](https://developer.android.com/reference/android/support/test/filters/SmallTest) instead. New tests should be written using the [Android Testing Support Library](https://developer.android.com/tools/testing-support-library).* | | [Smoke](https://developer.android.com/reference/android/test/suitebuilder/annotation/Smoke) | *This @interface was deprecated in API level 24. New tests should be written using the [Android Testing Support Library](https://developer.android.com/tools/testing-support-library).* | | [Suppress](https://developer.android.com/reference/android/test/suitebuilder/annotation/Suppress) | *This @interface was deprecated in API level 24. Use [Suppress](https://developer.android.com/reference/android/support/test/filters/Suppress) instead. New tests should be written using the [Android Testing Support Library](https://developer.android.com/tools/testing-support-library).* | | [SuppressLint](https://developer.android.com/reference/android/annotation/SuppressLint) | Indicates that Lint should ignore the specified warnings for the annotated element. | | [SuppressWarnings](https://developer.android.com/reference/java/lang/SuppressWarnings) | Indicates that the named compiler warnings should be suppressed in the annotated element (and in all program elements contained in the annotated element). | | [Target](https://developer.android.com/reference/java/lang/annotation/Target) | Indicates the contexts in which an annotation interface is applicable. | | [TargetApi](https://developer.android.com/reference/android/annotation/TargetApi) | Indicates that Lint should treat this type as targeting a given API level, no matter what the project target is. | | [TestTarget](https://developer.android.com/reference/dalvik/annotation/TestTarget) | *This @interface was deprecated in API level 14. Obsolete.* | | [TestTargetClass](https://developer.android.com/reference/dalvik/annotation/TestTargetClass) | *This @interface was deprecated in API level 14. Obsolete.* | | [UiThreadTest](https://developer.android.com/reference/android/test/UiThreadTest) | *This @interface was deprecated in API level 24. Use [UiThreadTest](https://developer.android.com/reference/android/support/test/annotation/UiThreadTest) instead. New tests should be written using the [Android Testing Support Library](https://developer.android.com/tools/testing-support-library).* | | [ViewDebug.CapturedViewProperty](https://developer.android.com/reference/android/view/ViewDebug.CapturedViewProperty) | This annotation can be used to mark fields and methods to be dumped when the view is captured. | | [ViewDebug.ExportedProperty](https://developer.android.com/reference/android/view/ViewDebug.ExportedProperty) | This annotation can be used to mark fields and methods to be dumped by the view server. | | [ViewDebug.FlagToString](https://developer.android.com/reference/android/view/ViewDebug.FlagToString) | Defines a mapping from a flag to a String. | | [ViewDebug.IntToString](https://developer.android.com/reference/android/view/ViewDebug.IntToString) | Defines a mapping from an int value to a String. | |

<br />

*** ** * ** ***

The common interface extended by all annotation interfaces. Note that an
interface that manually extends this one does *not* define
an annotation interface. Also note that this interface does not itself
define an annotation interface.

More information about annotation interfaces can be found in section
{@jls 9.6} of The Java Language Specification.

The `https://developer.android.com/reference/java/lang/reflect/AnnotatedElement` interface discusses
compatibility concerns when evolving an annotation interface from being
non-repeatable to being repeatable.

## Summary

| ### Public methods ||
|---|---|
| ` abstract https://developer.android.com/reference/java/lang/Class<? extends https://developer.android.com/reference/java/lang/annotation/Annotation>` | ` https://developer.android.com/reference/java/lang/annotation/Annotation#annotationType()() ` Returns the annotation interface of this annotation. |
| ` abstract boolean` | ` https://developer.android.com/reference/java/lang/annotation/Annotation#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Returns true if the specified object represents an annotation that is logically equivalent to this one. |
| ` abstract int` | ` https://developer.android.com/reference/java/lang/annotation/Annotation#hashCode()() ` Returns the hash code of this annotation. |
| ` abstract https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/lang/annotation/Annotation#toString()() ` Returns a string representation of this annotation. |

## Public methods

### annotationType

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract Class<? extends Annotation> annotationType ()
```

Returns the annotation interface of this annotation.

<br />

##### API Note:

- Implementation-dependent classes are used to provide the implementations of annotations. Therefore, calling `https://developer.android.com/reference/java/lang/Object#getClass()` on an annotation will return an implementation-dependent class. In contrast, this method will reliably return the annotation interface of the annotation.

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/Class<? extends https://developer.android.com/reference/java/lang/annotation/Annotation>` | the annotation interface of this annotation <br /> |

**See also:**

- `https://developer.android.com/reference/java/lang/Enum#getDeclaringClass()`

### equals

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract boolean equals (Object obj)
```

Returns true if the specified object represents an annotation
that is logically equivalent to this one. In other words,
returns true if the specified object is an instance of the same
annotation interface as this instance, all of whose members are equal
to the corresponding member of this annotation, as defined below:

- Two corresponding primitive typed members whose values are `x` and `y` are considered equal if `x == y`, unless their type is `float` or `double`.
- Two corresponding `float` members whose values are `x` and `y` are considered equal if `Float.valueOf(x).equals(Float.valueOf(y))`. (Unlike the `==` operator, NaN is considered equal to itself, and `0.0f` unequal to `-0.0f`.)
- Two corresponding `double` members whose values are `x` and `y` are considered equal if `Double.valueOf(x).equals(Double.valueOf(y))`. (Unlike the `==` operator, NaN is considered equal to itself, and `0.0` unequal to `-0.0`.)
- Two corresponding `String`, `Class`, enum, or annotation typed members whose values are `x` and `y` are considered equal if `x.equals(y)`. (Note that this definition is recursive for annotation typed members.)
- Two corresponding array typed members `x` and `y` are considered equal if `Arrays.equals(x, y)`, for the appropriate overloading of `https://developer.android.com/reference/java/util/Arrays#equals(T[],%20T[],%20java.util.Comparator<?%20super%20T>)`.

<br />

<br />

| Parameters ||
|---|---|
| `obj` | `Object` <br /> |

| Returns ||
|---|---|
| `boolean` | true if the specified object represents an annotation that is logically equivalent to this one, otherwise false <br /> |

### hashCode

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract int hashCode ()
```

Returns the hash code of this annotation.

The hash code of an annotation is the sum of the hash codes
of its members (including those with default values).

The hash code of an annotation member is (127 times the hash code
of the member-name as computed by `https://developer.android.com/reference/java/lang/String#hashCode()`) XOR
the hash code of the member-value.
The hash code of a member-value depends on its type as defined below:

- The hash code of a primitive value *`v`* is equal to `*WrapperType*.valueOf(*v*).hashCode()`, where *`WrapperType`* is the wrapper type corresponding to the primitive type of *`v`* (`https://developer.android.com/reference/java/lang/Byte`, `https://developer.android.com/reference/java/lang/Character`, `https://developer.android.com/reference/java/lang/Double`, `https://developer.android.com/reference/java/lang/Float`, `https://developer.android.com/reference/java/lang/Integer`, `https://developer.android.com/reference/java/lang/Long`, `https://developer.android.com/reference/java/lang/Short`, or `https://developer.android.com/reference/java/lang/Boolean`).
- The hash code of a string, enum, class, or annotation member-value *`v`* is computed as by calling `*v*.hashCode()`. (In the case of annotation member values, this is a recursive definition.)
- The hash code of an array member-value is computed by calling the appropriate overloading of `https://developer.android.com/reference/java/util/Arrays#hashCode(long[])` on the value. (There is one overloading for each primitive type, and one for object reference types.)

<br />

<br />

| Returns ||
|---|---|
| `int` | the hash code of this annotation <br /> |

### toString

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public abstract String toString ()
```

Returns a string representation of this annotation. The details
of the representation are implementation-dependent, but the following
may be regarded as typical:

```
   @com.example.Name(first="Duke", middle="of", last="Java")
 
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a string representation of this annotation <br /> |