1.所谓反射就是:一个 在运行时,可以知道自己的 属性和方法,
通过 obj类的 forname();可以获取每个类的对应对象,
getMethod("printinfo");//获取某一个方法
getMethods();获取的是所有的方法,变成一个数组
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
在try里面都是 eg:Class cls=Class.forname("com.xt.stu");
1. Method[] m=cls.getMethods();
可以遍历 for(Method mmm:m){syso--mmm.getName();}
2. Method mm=cls.getMethod(“printinfo”,String.class);//如果有 参数
执行就是mm.invoke(cls.newInstance(),"年龄");
如果是由返回参数的:Obj val=mm.invoke(cls.newInstance(),"年龄");
int res=Interger.parseInt(val.toString());//转变化为 可输出的
Class rtype=mm.getReturntype();//这是返回值的类型
rtype.getName()); //获取名字