java 自定义注解
package com.tedu.in;
import java.lang.reflect.Field;
public class Test {
public static void main(String[] args) {
Class<User> user = User.class;
Field[] fs = user.getDeclaredFields();
for (Field f : fs) {
// 获取属性上是否存在制定的注解
inter annotation = f.getAnnotation(inter.class);
// 判断annotation是否为空
if (annotation!=null){
// 获取注解的内容
String value = annotation.value();
System.out.println(annotation.value());
}else {
System.out.println("没有找到制定的注解");
}
}
}
}
本文来自博客园,作者:竹石2020,转载请注明原文链接:https://www.cnblogs.com/ch2020/p/16878794.html
浙公网安备 33010602011771号