Method getMethod=c.getMethod(getMethodName)
String value=(String)getMethod.invoke(f)
String value=(String)getMethod.invoke(f)
2017-05-08
@Target({ElementType.FIFLD,ElementType.TYPE,ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME,RetentionPolicy.SOURCE,RetentionPolicy.CLASS)
Class c=Class.forName("me.fixyou.Child");
c.isAnnotationPresent(MyDescription.class);
MyDescritption c=c.getAnnotation(MyDescription.class)
dd.value();
@Retention(RetentionPolicy.RUNTIME,RetentionPolicy.SOURCE,RetentionPolicy.CLASS)
Class c=Class.forName("me.fixyou.Child");
c.isAnnotationPresent(MyDescription.class);
MyDescritption c=c.getAnnotation(MyDescription.class)
dd.value();
2017-05-08
注解,介于注释与代码之间的东西,添加注释之后,需要用反射方法调用解析注解。
注解有两层含义:
1, 给程序员看的,解释类,方法或者变量的用途 (目的和// /* */ 类似)
2, 给编译器看的, 告诉编译器这个类,方法或者变量必须满足什么要求
注解有两层含义:
1, 给程序员看的,解释类,方法或者变量的用途 (目的和// /* */ 类似)
2, 给编译器看的, 告诉编译器这个类,方法或者变量必须满足什么要求
2017-05-07