package heimeTest;
public class Demo{
public static void main(String[] args) throws Exception{
Person p = (Person)Person.class.getConstructor(String.class,/*int.class*/Integer.TYPE).newInstance(new String("zhangsan"),13);
System.out.println(p);
}
}
class Person{
private String name;
private int age;
public Person(String name, int age){
this.name = name;
this.age = age;
}
public String toString(){
return name + ":" +age;
}
}
|