

package run;
import org.junit.Test;
import java.lang.reflect.Method;
public class FileDemo {
@Test
public void getMethods(){
Class c = Account.class;
Method[] methods = c.getMethods();
}
@Test
public void getDeclaredMethods(){
Class c = Account.class;
Method[] methods = c.getDeclaredMethods();
}
@Test
public void getMethod() throws Exception {
Class c = Account.class;
Method method = c.getMethod("eat");
}
@Test
public void getDeclaredMethod() throws Exception {
Class c = Account.class;
Method method = c.getDeclaredMethod("run",String.class);
method.setAccessible(true);
Object o = method.invoke(new Account(),"狗子");
System.out.println(o);
}