黑马程序员技术交流社区

标题: 求出错原因,看老师写的都不错啊!!! [打印本页]

作者: 张红(新)    时间: 2015-7-22 00:25
标题: 求出错原因,看老师写的都不错啊!!!
  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

求解决啊,看了好久都不知道咋了?
作者: 以梦为码    时间: 2015-7-22 00:44
这不是异样,是错误。




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2