学习张老师的视到“成员变量的反射”这一节时,发现问题,百度找了也没有找出来,求助!
public class ReflectPoint {
private int x ;
private int y;
public ReflectPoint(int x, int y) {
super();
this.x = x;
this.y = y;
}
}
public class ReflectTest {
public static void main(String[] args) throws Exception {
ReflectPoint pt1 = new ReflectPoint(3,5);
Field fieldY = pt1.getClass().getField("y");
/*这里为什么张老师编译运行都正常,我编译时却报错?“Field cannot be resolved to a type”*/
Syetem.out.println(fieldY.get(pt1));
}
}
刚学会玩Eclipse,是不是与设置有关,还是什么问题,请哪位大哥解答一下,谢谢!
|