07 2022 档案

摘要:1.Java静态代理举例: 代理类和被代理类在编译期间就已经确定下来了 1 interface ClothFactory{ 2 void produceCloth(); 3 } 4 5 class ProxyClothFactory implements ClothFactory{ 6 privat 阅读全文
posted @ 2022-07-11 15:26 jue1e0 阅读(107) 评论(0) 推荐(0) 编辑
摘要:1.调用运行时类的属性 1 public static void testField() throws Exception { 2 Class clazz = Person.class; 3 //创建运行时类的对象 4 Person p = (Person) clazz.newInstance(); 阅读全文
posted @ 2022-07-11 12:58 jue1e0 阅读(62) 评论(0) 推荐(0) 编辑
摘要:1.获取运行时类的属性 1 public static void test1() { 2 Class clazz = Person.class; 3 //getFields():获取当前运行时类及其父类中声明为public访问权限的属性 4 Field[] fields = clazz.getFie 阅读全文
posted @ 2022-07-10 19:27 jue1e0 阅读(206) 评论(0) 推荐(0) 编辑
摘要:1.通过Java反射创建运行时类的对象: 1 public static void test1() throws InstantiationException, IllegalAccessException { 2 Class<Person> clazz = Person.class; 3 //本质 阅读全文
posted @ 2022-07-10 11:21 jue1e0 阅读(250) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示