概述
public class Test {
public void test(int x){
System.out.println(x);
}
public static void main(String[] args) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, InstantiationException {
//error: Exception in thread "main" java.lang.NoSuchMethodException: com.webex.learning.Test.test(java.lang.Integer)
/* Class<?> forName = Class.forName("com.webex.learning.Test");
Method method = forName.getDeclaredMethod("test", Integer.class);
method.invoke(forName.newInstance(), 10);*/
Class<?> forName = Class.forName("com.webex.learning.Test");
Method method = forName.getDeclaredMethod("test", int.class);
method.invoke(forName.newInstance(), 10);
}
}
测试了下:
说明(1)int.Class=Integer.TYPE,但是和integer.class不是一回事情
最后
以上就是殷勤灯泡为你收集整理的int.Class和integer.class不是一回事的全部内容,希望文章能够帮你解决int.Class和integer.class不是一回事所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复