黑马程序员技术交流社区
标题:
大家看看我这个程序怎么运行不了啊
[打印本页]
作者:
会飞的狼
时间:
2013-8-14 18:31
标题:
大家看看我这个程序怎么运行不了啊
package com.itheima;
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class InstroSpectorText {
public static void main(MainParameter parameterObject) throws Exception{
ReflectPoint rpt1 =new ReflectPoint(3,5);
String PropertyName = "x";
getProperty(rpt1, PropertyName);
int x = 7;
setProperty(rpt1, PropertyName, x);
}
private static void setProperty(ReflectPoint rpt1, String PropertyName,
int x) throws IntrospectionException, IllegalAccessException,
InvocationTargetException {
PropertyDescriptor pd1 = new PropertyDescriptor(PropertyName, ReflectPoint.class);
Method pw = pd1.getWriteMethod();
pw.invoke(rpt1, x);
System.out.println(rpt1.getX());
}
private static void getProperty(ReflectPoint rpt1, String PropertyName)
throws IntrospectionException, IllegalAccessException,
InvocationTargetException {
PropertyDescriptor pd = new PropertyDescriptor(PropertyName, ReflectPoint.class);
Method pr = pd.getReadMethod();
System.out.println(pr.invoke(rpt1));
}
}
我是按章张老师的视频一步步写的,重构了方法之后就运行不了,提示出现重大错误,系统即将停止!怪吓人的
作者:
王靖远
时间:
2013-8-14 19:12
public static void main(MainParameter parameterObject)
我想知道这是什么。
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2