java.lang.annotation.ElementType:
A program element type. The constants of this enumerated type provide a simple classification of the declared elements in a Java program. These constants are used with the Target meta-annotation type to specify where it is legal to use an annotation type.
There are the following constants:
- ANNOTATION_TYPE – Annotation type declaration
- CONSTRUCTOR – Constructor declaration
- FIELD – Field declaration (includes enum constants)
- LOCAL_VARIABLE – Local variable declaration
- METHOD – Method declaration
- PACKAGE – Package declaration
- PARAMETER – Parameter declaration
- TYPE – Class, interface (including annotation type), or enum declaration
Can someone explain what each of them are (where they’d be annotated in actual code)?
This summarizes the main ones:
ANNOTATION_TYPE is an annotation on another annotation, like this:
Package is defined in a
package-info.javafile in the package, like this:For more info on PACKAGE annotations see here and here.