How to get annotation values in java reflection
问题 I have class Person: @Retention(RetentionPolicy.RUNTIME) @interface MaxLength { int length(); } @Retention(RetentionPolicy.RUNTIME) @interface NotNull { } public class Person { private int age; private String name; public Person(int age, String name) { this.age = age; this.name = name; } @NotNull public int getAge() { return this.age; } @MaxLength(length = 3) public String getName() { return this.name; } } Then I'm trying to print annotation values of methods of Peson object. for (Method