标题: Field 类的存储问题 [打印本页] 作者: 赵国刚 时间: 2013-8-10 18:56 标题: Field 类的存储问题
关于Field 类对成员变量的反射之后:
<div>public class ReflectPoint {</div><div> private int x ;</div><div> public int y ;</div><div> public ReflectPoint(int x, int y) {</div><div> super();</div><div> this.x = x;</div><div> this.y = y;</div><div> }</div><div> </div><div> public static void ReflectText() throws Exception{ </div><div> ReflectPoint point_1 = new ReflectPoint(3,4);</div><div> ReflectPoint point_2 = new ReflectPoint(5,10);</div><div> Field fieldY = point_1.getClass().getField("y") ;</div><div> System.out.println(fieldY.get(point_2)); </div><div> }</div><div> public static void main(String[] args) throws Exception {</div><div> ReflectText() ;</div><div> } </div><div> }</div>