[AppleScript] 纯文本查看 复制代码 public class Game {
public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException, InstantiationException {
Class<?> c = Class.forName("cn.itcast.lh.Entry");//获取Class类的对象
Constructor<?> con = c.getConstructor();
Method m = c.getDeclaredMethod("begin");
m.setAccessible(true);
Object obj = con.newInstance();
m.invoke(obj);
Class<?> roo = Class.forName("cn.itcast.lh.Room");//获取Class对象
Constructor<?> goo= roo.getDeclaredConstructor();//通过构造方法创建对象
goo.setAccessible(true);
Method te = roo.getDeclaredMethod("tellMe");//通过对象获取方法
te.setAccessible(true);
Object ob = goo.newInstance();
te.invoke(ob);
Method te1 = roo.getDeclaredMethod("tellMe", int.class);
te1.setAccessible(true);
Object ob1 = goo.newInstance();
te1.invoke(ob1,24);
|