//Student类
public class Student {
public void love() {
System.out.println("python");
} }
//Tesy类
public class Tesy {
public static void main(String[] args) throws Exception {
Properties prop=new Properties();
FileReader f=new FileReader("test.txt");
prop.load(f);
f.close();
String className=prop.getProperty("className");
String methodName=prop.getProperty("methodName");
//反射
Class c=Class.forName(className);
Constructor c1=c.getConstructor();
Object obj=c1.newInstance();
Method m=c.getMethod(methodName);
m.invoke(obj);
} }
//test.txt className=test.reflection.Student(包名类名) methodName=love