- Java code
package cn.pb.constructor;import java.lang.reflect.Constructor;import java.lang.reflect.InvocationTargetException;import java.util.Calendar;public class Main { public static void main(String[] args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException { Class cla=Calendar.class; Calendar cal=(Calendar) cla.newInstance(); System.out.println(cal.toString()); }}
运行时抛出java.lang.IllegalAccessException异常,求高手解答。
------解决方案--------------------------------------------------------
e...
我的意思是 你不能去newInstance一个非public的类构造器。