The method newInstance() from the type Class<capture#4-of ?> is deprecated
反射实例化对象clazz.getDeclaredConstructor().newInstance()跟class.newInstance()
//使用 Object中的getClass() 方法获得
Class dateClass_1=date.getClass();
//使用 类名.class 来获取
//这个是JVM支持的,但是得先把包导进来
Class dateClass_2=Date.class;
//利用Class中的forName()方法获取类
Class dateCLass_3 = Class.forName("java.util.Date");
//1.9之后不能用了,因为只能调用无参构造,没办法构
Object objPerson1 =instanceObj.newInstance();
//1.9之后采用这个来实例化对象
//这里要注意不是getDeclaredConstructors
Object objPerson2 = instanceObj.getDeclaredConstructor().newInstance();
浙公网安备 33010602011771号