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

# ElementType


`
public

final

enum
ElementType
`


`


`

`

extends https://developer.android.com/reference/java/lang/Enum<https://developer.android.com/reference/java/lang/annotation/ElementType>


`

`


`

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [java.lang.Enum](https://developer.android.com/reference/java/lang/Enum)\<[java.lang.annotation.ElementType](https://developer.android.com/reference/java/lang/annotation/ElementType)\> ||
|   | ↳ | java.lang.annotation.ElementType |

<br />

*** ** * ** ***

The constants of this enumerated class provide a simple classification of the
syntactic locations where annotations may appear in a Java program. These
constants are used in `https://developer.android.com/reference/java/lang/annotation/Target`
meta-annotations to specify where it is legal to write annotations of a
given type.

The syntactic locations where annotations may appear are split into
*declaration contexts* , where annotations apply to declarations, and
*type contexts*, where annotations apply to types used in
declarations and expressions.

The constants `https://developer.android.com/reference/java/lang/annotation/ElementType#ANNOTATION_TYPE`, `https://developer.android.com/reference/java/lang/annotation/ElementType#CONSTRUCTOR`, `https://developer.android.com/reference/java/lang/annotation/ElementType#FIELD`, `https://developer.android.com/reference/java/lang/annotation/ElementType#LOCAL_VARIABLE`, `https://developer.android.com/reference/java/lang/annotation/ElementType#METHOD`, `https://developer.android.com/reference/java/lang/annotation/ElementType#PACKAGE`, `https://developer.android.com/reference/java/lang/annotation/ElementType#MODULE`, `https://developer.android.com/reference/java/lang/annotation/ElementType#PARAMETER`, `https://developer.android.com/reference/java/lang/annotation/ElementType#TYPE`, and `https://developer.android.com/reference/java/lang/annotation/ElementType#TYPE_PARAMETER`
correspond to the declaration contexts in JLS 9.6.4.1.

For example, an annotation whose interface is meta-annotated with
`@Target(ElementType.FIELD)` may only be written as a modifier for a
field declaration.

The constant `https://developer.android.com/reference/java/lang/annotation/ElementType#TYPE_USE` corresponds to the type contexts in JLS
4.11, as well as to two declaration contexts: class and interface
declarations (including annotation declarations) and type parameter
declarations.

For example, an annotation whose interface is meta-annotated with
`@Target(ElementType.TYPE_USE)` may be written on the class or
interface of a field (or within the class or interface of the field, if it
is a nested or parameterized class or interface, or array class), and may
also appear as a modifier for, say, a class declaration.

The `TYPE_USE` constant includes class and interface declarations
and type parameter declarations as a convenience for designers of
type checkers which give semantics to annotation interfaces. For example,
if the annotation interface `NonNull` is meta-annotated with
`@Target(ElementType.TYPE_USE)`, then `@NonNull`
`class C {...}` could be treated by a type checker as indicating that
all variables of class `C` are non-null, while still allowing
variables of other classes to be non-null or not non-null based on whether
`@NonNull` appears at the variable's declaration.

## Summary

| ### Enum values ||
|---|---|
| `https://developer.android.com/reference/java/lang/annotation/ElementType` | `ANNOTATION_TYPE` Annotation interface declaration (Formerly known as an annotation type.) |
| `https://developer.android.com/reference/java/lang/annotation/ElementType` | `CONSTRUCTOR` Constructor declaration |
| `https://developer.android.com/reference/java/lang/annotation/ElementType` | `FIELD` Field declaration (includes enum constants) |
| `https://developer.android.com/reference/java/lang/annotation/ElementType` | `LOCAL_VARIABLE` Local variable declaration |
| `https://developer.android.com/reference/java/lang/annotation/ElementType` | `METHOD` Method declaration |
| `https://developer.android.com/reference/java/lang/annotation/ElementType` | `MODULE` Module declaration. |
| `https://developer.android.com/reference/java/lang/annotation/ElementType` | `PACKAGE` Package declaration |
| `https://developer.android.com/reference/java/lang/annotation/ElementType` | `PARAMETER` Formal parameter declaration |
| `https://developer.android.com/reference/java/lang/annotation/ElementType` | `RECORD_COMPONENT` Record component |
| `https://developer.android.com/reference/java/lang/annotation/ElementType` | `TYPE` Class, interface (including annotation interface), enum, or record declaration |
| `https://developer.android.com/reference/java/lang/annotation/ElementType` | `TYPE_PARAMETER` Type parameter declaration |
| `https://developer.android.com/reference/java/lang/annotation/ElementType` | `TYPE_USE` Use of a type |

| ### Public methods ||
|---|---|
| ` static https://developer.android.com/reference/java/lang/annotation/ElementType` | ` https://developer.android.com/reference/java/lang/annotation/ElementType#valueOf(java.lang.String)(https://developer.android.com/reference/java/lang/String name) ` |
| ` static final https://developer.android.com/reference/java/lang/annotation/ElementType` | ` https://developer.android.com/reference/java/lang/annotation/ElementType#values()() ` |

### Inherited methods

From class `

https://developer.android.com/reference/java/lang/Enum

` `


final

https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Enum#clone()()
`

Throws CloneNotSupportedException.


`


final

int` `
https://developer.android.com/reference/java/lang/Enum#compareTo(E)(E o)
`

Compares this enum with the specified object for order.


`


final

boolean` `
https://developer.android.com/reference/java/lang/Enum#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object other)
`

Returns true if the specified object is equal to this
enum constant.


`


final

void` `
https://developer.android.com/reference/java/lang/Enum#finalize()()
`

enum classes cannot have finalize methods.


`


final

https://developer.android.com/reference/java/lang/Class<E>` `
https://developer.android.com/reference/java/lang/Enum#getDeclaringClass()()
`

Returns the Class object corresponding to this enum constant's
enum type.


`


final

int` `
https://developer.android.com/reference/java/lang/Enum#hashCode()()
`

Returns a hash code for this enum constant.


`


final

https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Enum#name()()
`

Returns the name of this enum constant, exactly as declared in its
enum declaration.


`


final

int` `
https://developer.android.com/reference/java/lang/Enum#ordinal()()
`

Returns the ordinal of this enumeration constant (its position
in its enum declaration, where the initial constant is assigned
an ordinal of zero).


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Enum#toString()()
`

Returns the name of this enum constant, as contained in the
declaration.


`


static

<T extends https://developer.android.com/reference/java/lang/Enum<T>>
T` `
https://developer.android.com/reference/java/lang/Enum#valueOf(java.lang.Class<T>,%20java.lang.String)(https://developer.android.com/reference/java/lang/Class<T> enumClass, https://developer.android.com/reference/java/lang/String name)
`

Returns the enum constant of the specified enum class with the
specified name.


From class `

https://developer.android.com/reference/java/lang/Object

` `


https://developer.android.com/reference/java/lang/Object` `
https://developer.android.com/reference/java/lang/Object#clone()()
`

Creates and returns a copy of this object.


`


boolean` `
https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj)
`

Indicates whether some other object is "equal to" this one.


`


void` `
https://developer.android.com/reference/java/lang/Object#finalize()()
`

Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.


`


final

https://developer.android.com/reference/java/lang/Class<?>` `
https://developer.android.com/reference/java/lang/Object#getClass()()
`

Returns the runtime class of this `Object`.


`


int` `
https://developer.android.com/reference/java/lang/Object#hashCode()()
`

Returns a hash code value for the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notify()()
`

Wakes up a single thread that is waiting on this object's
monitor.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#notifyAll()()
`

Wakes up all threads that are waiting on this object's monitor.


`


https://developer.android.com/reference/java/lang/String` `
https://developer.android.com/reference/java/lang/Object#toString()()
`

Returns a string representation of the object.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis)
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*, or until a
certain amount of real time has elapsed.


`


final

void` `
https://developer.android.com/reference/java/lang/Object#wait()()
`

Causes the current thread to wait until it is awakened, typically
by being *notified* or *interrupted*.


From interface `

https://developer.android.com/reference/java/lang/Comparable

` `
abstract


int` `
https://developer.android.com/reference/java/lang/Comparable#compareTo(T)(E o)
`

Compares this object with the specified object for order.


## Enum values

### ANNOTATION_TYPE

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

```
public static final ElementType ANNOTATION_TYPE
```

Annotation interface declaration (Formerly known as an annotation type.)

<br />

### CONSTRUCTOR

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

```
public static final ElementType CONSTRUCTOR
```

Constructor declaration

<br />

### FIELD

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

```
public static final ElementType FIELD
```

Field declaration (includes enum constants)

<br />

### LOCAL_VARIABLE

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

```
public static final ElementType LOCAL_VARIABLE
```

Local variable declaration

<br />

### METHOD

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

```
public static final ElementType METHOD
```

Method declaration

<br />

### MODULE

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

```
public static final ElementType MODULE
```

Module declaration.

<br />

### PACKAGE

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

```
public static final ElementType PACKAGE
```

Package declaration

<br />

### PARAMETER

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

```
public static final ElementType PARAMETER
```

Formal parameter declaration

<br />

### RECORD_COMPONENT

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

```
public static final ElementType RECORD_COMPONENT
```

Record component

<br />

### TYPE

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

```
public static final ElementType TYPE
```

Class, interface (including annotation interface), enum, or record
declaration

<br />

### TYPE_PARAMETER

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

```
public static final ElementType TYPE_PARAMETER
```

Type parameter declaration

<br />

### TYPE_USE

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

```
public static final ElementType TYPE_USE
```

Use of a type

<br />

## Public methods

### valueOf

```
public static ElementType valueOf (String name)
```

<br />

<br />

| Parameters ||
|---|---|
| `name` | `String` <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/annotation/ElementType` | <br /> |

### values

```
public static final ElementType[] values ()
```

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/annotation/ElementType` | <br /> |