package arrayList;
import java.lang.reflect.*;
@Retention(RetentionPolicy.RUNTIME)
@Interface MyAnnotation{
String Author();
String Date();
}
@MyAnnotation(Author = "Dulvin",Date = "06/01/2013")
public class annotations {
@MyAnnotation(Author = "Dulvin", Date = "Today")
public static void Display(){
System.out.println("Annotation Starts");
}
public static void main(String[] args){
Display();
AnnotationCall();
}
public static void AnnotationCall(){
annotations ann = new annotations();
try{
Class c = ann.getClass();
Method m = c.getMethod("Display");
MyAnnotation a1 = (MyAnnotation)c.getAnnotation(MyAnnotation.class);
MyAnnotation a2 = (MyAnnotation)m.getAnnotation(MyAnnotation.class);
System.out.println("Class " + a1.Author());
System.out.println("class " + a1.Date());
System.out.println("Method " + a2.Author());
System.out.println("Method " + a2.Date());
}
catch (NoSuchMethodException ex){
System.out.println("NosuchMethod " + ex.getMessage());
}
}
}
"Exception in thread "main" java.lang.Error: Unresolved compilation problem:
at arrayList.annotations.main(annotations.java:20)
" - is the error