You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The string "hello" is assigned to the str member of MyAnno.
when an annotation member is given a value, only its name is used. hence, annotation members look like fields here.
Annotation Retention Policy
A retention policy determines at what point an annotation is discarded.
java defines three such policy which are encapsulated within the java.lang.annotation.RetentionPolicy enumeration.
They are : SOURCE , CLASS(default), RUNTIME
SOURCE : An annotation with this retention policy is retained only in the source fie and is discarded during compilation.
CLASS : An annotation with this retention policy is stored in the .class file during compilation. however it is not available through JVM during runtime.
RUNTIME : An annotation with this retention policy is stored in the .class file during compilation and is available through JVM during runtime.
Runtime offers the greatest annotation persistence.
An annotation on a local variable declaration is not retained in the .class file.