1.先獲取這個類的class
Class<?> objclass=t.getClass();
2. 獲取這個類的字段屬性
Field[] at = objclass.getDeclaredFields();
3.遍歷所有字段
for (Field fd : at) {
//比如獲取這個字段上是否包含NotNull
if (fd.isAnnotationPresent(NotNull.class)) {
//這樣就獲取到這個註解屬性了
NotNull d = fd.getAnnotation(NotNull.class);
}
}
4.要獲取壹個註解,妳要先獲取他所在的字段
希望對妳有幫助!