2012年4月14日

Java中通过反射调用其他类中的main方法时要注意的问题

摘要: 一、正常情况下我们调用其他类的方法,如果是静态的,就直接:类名.方法 ;如果不是静态的:对象.方法;因为main为静态方法,所以调用它只需:类名.main(String...args)即可。二、用反射方式来调用,我们往调用类的main方法中的参数传入被调用类的类全名,然后根据该类名来执行main方法public class invokeClassMainMethod { public static void main(String[] args) throws Exception { Method startClassMainMethod= Class.forName(args[0]).ge. 阅读全文

posted @ 2012-04-14 10:21 duancanmeng 阅读(1559) 评论(0) 推荐(0) 编辑

导航