求指教,java反射去Annotation
如题:
##自定义Annotation##
public @interface MyAnnotation {
String role();
}
##Users类##
public class User {
@MyAnnotation(role="aaa")
public void say()
{
System.out.println("HI!");
}
}
##Main方法##
Class a=Class.forName("Users");
Method [] method=a.getMethods();
for (int i = 0; i < method.length; i++) {
System.out.println(method[i].getName());
System.out.println(method[i].getAnnotations().length);
}
结果Say方法为的Annotations为0;
为什么?