Integer.valueOf()和Integer.ParseInt()的区别

来源:互联网 发布:飞机销售网软件 编辑:程序博客网 时间:2024/05/17 06:36
Integer.valueOf()返回一个Integer对象而Integer.ParseInt()是返回一个Int对象两种对象不同int是基本的数据类型,直接存数值;Integer是int的封装类;integer 是对象,用一个引用指向这个对象;Integer 是一个类,是int的扩展,定义了很多的转换方法。int和Integer都可以表示某一个数值;int和Integer不能够互用,因为他们两种不同的数据类型;    举例说明  ArrayList al=new ArrayList();  int n=40;  Integer nI=new Integer(n);  al.add(n);//不可以    al.add(nI);//可以integer 是对象,用一个引用指向这个对象。