- import java.lang.reflect.*;
- class A{
- public void show(){
- System.out.println("wo shi ge ren");
- }
- }
- public class Test{
- public static void main(String[]args)throws Exception{
- Class c=A.class;
- A a=(A)c.newInstance();
- Method method=c.getMethod("show");
- method.invoke(a);
-
- }
- }
复制代码 |
|