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