1 Star 0 Fork 1

LiuYan/Java

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
Part02.java 591 Bytes
一键复制 编辑 原始数据 按行查看 历史
liuyan 提交于 2023-05-10 13:21 +08:00 . java9、java10、java11
package reflection;
import annotation.MyAnno;
/**
* @author LiuYan
* @date 2021/11/16 16:05
*/
public class Part02 {
public static void main(String[] args) {
Class<Person> personClass = Person.class;
boolean annotationPresent = personClass.isAnnotationPresent(MyAnno.class);
if (annotationPresent) {
MyAnno annotation = personClass.getAnnotation(MyAnno.class);
System.out.println(annotation.season());
// 获取注解中的注解值报错
// System.out.println(annotation.myAnno2());
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/Liu-Yan-Code/java.git
git@gitee.com:Liu-Yan-Code/java.git
Liu-Yan-Code
java
Java
master

搜索帮助