日期:2014-05-20 浏览次数:20726 次
import java.lang.reflect.Method; public class StubTest { public static void main(String[] args) throws Exception{ Class<?> clazz= Class.forName("com.nbinfo.test.StubTest"); Object ob = clazz.newInstance(); Method method = clazz.getMethod("showMsg", String.class); method.invoke(ob, "HelloWorld"); } public void showMsg(String msg){ System.out.println(msg); } }