int.Class和integer.class不是一回事
2011-09-28 14:11
232 查看
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不是一回事情
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不是相同的class对象
- int.class与Integer.type的不同
- iBaits中,关于insert返回值的问题(注意!!!不必写resultClass= "java.lang.Integer",方法的返回值就是int)
- Hibernate Tip: 为什么要把变量类型设置为Long, Integer,而不是long, int
- java基础——path and classpath,int and Integer,Array and Arrays(初学时的疑惑)
- int.class与Integer.type的不同
- 和大家讨论一下 int.class 与 Integer.class?
- int.class 与 Integer.class
- 定义变量的时候为什么用的是Integer而不是int
- int.class和Integer.class有何不同?
- 如果不空null并且不是空字符串才去修改这个值,但这样写只能针对字符串(String)类型,如果是Integer类型的话就会有问题了。 int i = 0; i!=''。 mybatis中会返回tr
- 为什么数据库表的int类型字段映射到实体类中要使用Integer类型,而不是int类型?
- int.class和Integer.class
- Int 与integer的简单区别
- Integer和int之间==的比较问题
- Java的Integer与int互转
- 真理和想像中的不是一回事
- C# 中WebService返回类型(string,int,bool,DataSet,class实体类)示例
- 利用write(int)方法写入一个int型的数据为什么看见的却不是整形的数据?
- JDK1.4中int数组转换成integer数组的方法