public static void main(String[] args) throws SecurityException, NoSuchFieldException, InstantiationException, IllegalAccessException {
// creadExcelByModule2();
ExcelCoordinateBean excelCoordinateBean = new ExcelCoordinateBean(6,6);
System.out.println(excelCoordinateBean.getClass().newInstance().getColumn());;
// creadExcelByModule2();
ExcelCoordinateBean excelCoordinateBean = new ExcelCoordinateBean(6,6);
System.out.println(excelCoordinateBean.getClass().newInstance().getColumn());;
}
打印结果:0
异常:
Exception in thread "main" java.lang.InstantiationException: com.joyplus.beans.ExcelCoordinateBean
at java.lang.Class.newInstance0(Class.java:342)
at java.lang.Class.newInstance(Class.java:310)
at com.joyplus.util.test.main(test.java:140)
异常含义:new Instance调用的是空参构造方法,如果没有就会报错,
同时注意newInstatnce产生的是一个新的实例对象,和以前的实例对象无关