本帖最后由 耶稣说wō乖 于 2013-8-26 14:55 编辑
上代码:
package cn.da;import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class Test07 {
public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException,SecurityException,NoSuchMethodException, InstantiationException {
Constructor<Demo> ca = Demo.class.getConstructor();
Demo d = ca.newInstance();
Method m = Demo.class.getMethod("print");
System.out.println(m.invoke(d));
}
}
class Demo
{
public Demo(){};
public void print()
{
System.out.println("woshishuaige");
}
}
为什么我的输出结果有个null?
我没给他写输出语句啊!
哪冒出来的
|