class Test{
public static void main(String [] args){
Method md = Test.class.getMethod("xxx");
System.out.println(md.getClass().isAnnotationPresent(Annotation1.class));
}
@Annotation1("aaa")
public void xxx(){
System.out.println("xxx");
}
}
@Retention(RetentionPolicy.RUNTIME)
public @interface Annotation1 {
String color() default "blue";
String value();
int [] arrayAttr() default {1,2,3};
}
为什么输出结果是false,如果方法不对,那么如何判断某个函数是否加了注解,请高手解答 |