Class[] argsClass = new Class[2];
argsClass[0] = Integer.class; argsClass[1] = String.class; User user2 = (User) userClass.getConstructor(argsClass).newInstance(new Object[]{12, "awe"});
报错信息:
java.lang.NoSuchMethodException: com.bean.User.<init>(java.lang.Integer, java.lang.String)
at java.base/java.lang.Class.getConstructor0(Class.java:3322) at java.base/java.lang.Class.getConstructor(Class.java:2108)
倚天杖
相关分类