The getDeclaredAnnotations() method of java.lang.reflect.Field is used to return annotations that are directly present on this Field object and ignores inherited annotations. If there are no annotations directly present on this element, the return value is an empty array. The caller can modify the returned array as method sent a copy of the actual object; it will have no effect on the arrays returned to other callers.
public Annotation getDeclaredAnnotations()
Parameters: This method accepts accepts nothing.
Return: This method returns annotations directly present on this element.
Below programs illustrate getDeclaredAnnotations() method:
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.