import java.io.PrintStream; import java.lang.reflect.Method; public final class AnnotationReader { public static void main(String[] args) throws Exception { out.println("Testing annotations where the method IS NOT " + "overridden by the sub-class"); Method m = Annotated.class.getMethod("foo"); if(m.isAnnotationPresent(Adelita.class)) out.println("Method 'foo' of Annotated has the Adelita annotation"); else out.println("Method 'foo' of Annotated does NOT have " + "the Adelita annotation"); out.println("Testing annotations where the method IS " + "overridden by the sub-class"); m = Annotated.class.getMethod("bar"); if(m.isAnnotationPresent(Adelita.class)) out.println("Method 'bar' of Annotated has the Adelita annotation"); else out.println("Method 'bar' of Annotated does NOT have " + "the Adelita annotation"); } private static final PrintStream out = System.out; }