黑马程序员技术交流社区

标题: 反射访问私有成员变量 [打印本页]

作者: 奋发吧小白    时间: 2014-9-3 21:25
标题: 反射访问私有成员变量
本帖最后由 奋发吧小白 于 2014-9-3 21:30 编辑
  1. package test;
  2. public class ReflectPoint {
  3.         private int x;
  4.         public int y;
  5.         public ReflectPoint(int x, int y) {
  6.                 super();
  7.                 this.x = x;
  8.                 this.y = y;
  9.         }
  10. }
复制代码
  1. import java.lang.reflect.Constructor;
  2. import java.lang.reflect.Field;
  3. import java.util.*;
  4. public class ReflaectTest {
  5.         public static void main(String[] args  ) throws  Exception {
复制代码








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