java 注解代码
package com.endual.annotation;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
public class MyRefection {
??
??? public static void main(String args[]) throws SecurityException, Exception{
??? ??? Class<HelloM> c = HelloM.class;
??? ??? HelloM m = new HelloM();
??? Method method = c.getMethod("sayHello", new Class[]{});
???
??? if(method.isAnnotationPresent(MyAnnotation.class)){
??? ??? method.invoke(m, new Object[]{});
??? ??? MyAnnotation annotation = method.getAnnotation(MyAnnotation.class);
??? ???
???????? String hello1 = annotation.value();
//?????? String hello = annotation.annotationType().getName();
//??????
?????? System.out.print(hello1);
??? }
? }
}