From 9a86a4c5f678508bac07b60fba12ae2c7cc829f8 Mon Sep 17 00:00:00 2001 From: heibaiying <31504331+heibaiying@users.noreply.github.com> Date: Fri, 27 Dec 2019 14:46:17 +0800 Subject: [PATCH] =?UTF-8?q?Update=20Java=5F=E5=8F=8D=E5=B0=84=E4=B8=8E?= =?UTF-8?q?=E6=B3=A8=E8=A7=A3.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- notes/Java_反射与注解.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/notes/Java_反射与注解.md b/notes/Java_反射与注解.md index 56164fe..b1be3a3 100644 --- a/notes/Java_反射与注解.md +++ b/notes/Java_反射与注解.md @@ -74,7 +74,7 @@ public Constructor getConstructor(Class... parameterTypes) public Constructor getDeclaredConstructor(Class... parameterTypes) ``` -获取指定的构造器后,可以使用 `newInstance` 方法来创建其实例,实例如下: +获取指定的构造器后,可以使用 `newInstance` 方法来创建其实例,示例如下: ```java class Test { @@ -287,8 +287,11 @@ public @interface Override { ```java // 获取所有注解 public Annotation[] getAnnotations() +// 获取本元素上直接声明的所有注解,忽略inherited来的 public Annotation[] getDeclaredAnnotations() +// 获取指定类型的注解,如果不存在则返回null public T getAnnotation(Class annotationClass) +// 判断是否有指定类型的注解 public boolean isAnnotationPresent(Class annotationClass) ``` @@ -310,7 +313,8 @@ class Test { /*当只有一个值并且其对应的方法名为value时候,可以省略value = */ @Json("姓名") private String name; - @Json(value = "出生日期", format = "yyyy-MM-dd HH:mm:ss") + + @Json(value = "出生日期", format = "yyyy-MM-dd HH:mm:ss") private Date birthday; ...... } @@ -379,4 +383,4 @@ class Test { ## 参考资料 -+ 马俊昌 . Java编程的逻辑 . 机械工业出版社 . 2018-01-01 \ No newline at end of file ++ 马俊昌 . Java编程的逻辑 . 机械工业出版社 . 2018-01-01