public class UserName {
protected void getMethod(String name) {
System.out.println(name + "成功获得method");
}
}
String classname1 = "com.meicai.test.prototype.UserName";
Class c1 = Class.forName(classname1);
Object object = c1.newInstance();
Method method = c1.getDeclaredMethod("getMethod", String.class);
method.setAccessible(true);
method.invoke(object, "张三");
执行结果
张三成功获得method