【转】

  Class c;
c = Class.forName("class name");
Method m = c.getMethod("method name", new Class[] {int.class, int.class, int.class,int.class});
m.invoke(c, new Object[] {1,2, 3, 4});

【例子】

 

 
    
  1. public class T { 
  2.     public static void aa(String t){ 
  3.         System.out.println(t+"T"); 
  4.     } 
  5.  
  6. public class Test { public static void main(String[] args) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { Class c; c = Class.forName("K"); Method m = c.getMethod("aa", new Class[] {String.class}); m.invoke(c, new Object[]{"test"}); } }