1.定义Person类,私有成员变量有name,age,公开成员变量有sex,成员方法包括gette和setter,构造方法有无参和全参,用反射去创建一个Person对象,用2种方式。
2.在第一题中加入方法show,打印一串字符串,利用反射执行该方法。
4.在第一题基础之上,利用反射设置name为“张三”,sex为“男”。
5.在第一题基础上,写一个Properties格式的配置文件,配置类的完整名称和所要执行的方法,写一个程序,读取这个Properties配置文件,获得类的完整名称并加载这个类,并执行读取的方法。
package home;
public class Person {
private String name;
private Integer age;
public String sex;
public Person() {
}
public Person(String name, Integer age, String sex) {
this.name = name;
this.age = age;
this.sex = sex;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public String getSex() {
return sex;
}