![]() |
VOOZH | about |
The getAnnotatedType() method of java.lang.reflect.Field is used to return an annonatedType object that represents the use of a type to specify the declared type of the field. Every Field of the class is declared by some AnnotatedType.AnnotatedType represents the potentially annotated use of any type including an array type, a parameterized type, a type variable, or a wildcard type currently running in Java Virtual Machine. The returned AnnotatedType instance can be an implementation of AnnotatedType itself or an implementation of one of its sub-interfaces: AnnotatedArrayType, AnnotatedParameterizedType, AnnotatedTypeVariable, AnnotatedWildcardType.
Syntax:
public AnnotatedType getAnnotatedType()
Parameters: This method accepts nothing. Return: This method returns an object representing the declared type of the field represented by this Field. Below programs illustrate getAnnotatedType() method:
Program 1:
Type: int Annotations: []
Program 2:
Type: int[] Annotations: [@GFG$SpecialNumber()] Declared Annotations: [@GFG$SpecialNumber()]
References: https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/Field.html#getAnnotatedType--