public static void main(String[] args) throws Exception
{
Class clazz = Class.forName("com.itheima.RyReflect");
Method method = clazz.getMethod("printString", String.class);
method.invoke(clazz.newInstance(), "reflect is String");
}
}
class RyReflect
{
public void printString(String str)
{
System.out.println(str);
}
}
|