1.自定义注解:
public @interface NoSetValue {
public int id() default 1;
public String description() default "";
}2.解析:
public class User {

@NoSetValue(id=2,description="asdf")        //自定义注解
public String getPass() {
//code here
} public String getUserName() {
//code here
}

public static void main(String[] args) {
Class c = User.class;

Method [] method = c.getDeclaredMethods();

for(Method temp : method){
if(temp.isAnnotationPresent(NoSetValue.class)){              //取被注解的方法名
System.out.println(temp.getName());
}
}
}打印时,为空。为什么取不到被注解的方法