A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

  1. public static void  getFieldDemo()throws Exception{
  2.                 String name="bean.Person";
  3.                 Class clazz=Class.forName(name);
  4.                 Field field=clazz.getDeclaredField("age");
  5.                 Object obj=clazz.newInstance();
  6.                 field.setAccessable(true);
  7.                 field.set(obj,89);
  8.                 Object o=field.get(obj);
  9.                
  10.         System.out.println(o);               
  11.                
  12.         }
复制代码

Field field=clazz.getDeclaredField("age");异常信息下面:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
        Field cannot be resolved to a type

求解决啊,看了好久都不知道咋了?

1 个回复

倒序浏览
这不是异样,是错误。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马