import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class ReflectTest {
public static void main(String[] args) throws Exception {
String str1="abc";
Method methodCharAt=String.class.getMethod("charAt", int.class);
System.out.println(methodCharAt.invoke(str1,2));
/*invoke 是方法对象methodCharAt上的方法,这个方法的作用是去调用
* methodCharAt对应的方法*/
}
}