摘要: 反射创建对象以及方法的使用 反射获取构造器 import java.lang.reflect.Constructor; public class Test { public static void main(String[] args) { try { Class clazz = Class.for 阅读全文
posted @ 2023-03-13 23:16 Geek李 阅读(49) 评论(0) 推荐(0)
摘要: 反射获得属性和方法 属性 获取public属性的方法 clazz.getFields() 获取全部属性的方法clazz.getDeclaredFields() 获得指定属性的值 clazz.getDeclaredField("name") 方法 获得所有本类及其父类的所有public方法 clazz 阅读全文
posted @ 2023-03-13 22:17 Geek李 阅读(27) 评论(0) 推荐(0)
摘要: 注解 元注解 元注解是用来给注解进行解释的,也就是注解的注解 @Target 这个是为我们自定义的注解进行权限说明的,也就是谁可以用这个注解 比如:@Target(ElementType.TYPE) 就是给类的注解 @Retention 这个注解是让被注解的元素什么时候有作用,比如RUNTIME就是 阅读全文
posted @ 2023-03-13 21:51 Geek李 阅读(30) 评论(0) 推荐(0)