标签:exception int ati str declared public getc oid 创建
/**public static void main(String[] args) throws Exception {
Class clazz = Class.forName("com.heima.bean.Person");
Constructor c = clazz.getConstructor(String.class,int.class); //获取有参构造
Person p = (Person) c.newInstance("张三",23); //通过有参构造创建对象
Method m = clazz.getMethod("eat"); //获取eat方法
m.invoke(p);
Method m2 = clazz.getMethod("eat", int.class); //获取有参的eat方法
m2.invoke(p, 10);
}
标签:exception int ati str declared public getc oid 创建
原文地址:http://blog.51cto.com/357712148/2158301