public class ReflectDemo {
public static void main(String[] args) throws NoSuchMethodException,
SecurityException, InstantiationException, IllegalAccessException,
IllegalArgumentException, InvocationTargetException {
//获取字节码对象
Class c=Person.class;
Constructor con=c.getConstructor(String.class,int.class);
Object obj=con.newInstance("林青霞",27);
System.out.println(obj);
}
|
|