Int与Integer的区别

int和integer的区别

      1. Ingeter是int的包装类,int的初值为0,Ingeter的初值为null;

      2.初始化的时候,int i =1;Integer i= new Integer(1);(要把integer 当做一个类看);但由于有了自动装箱和拆箱使得对Integer类也可使用:Integer i= 1;    

      3.int 是基本数据类型(面向过程留下的痕迹,不过是对java的有益补充),Integer 是一个类,是int的扩展,定义了很多的转换方法

      4.Integer是对象,用一个引用指向这个对象,而int是基本类型,直接存储数值。

原文地址:https://www.cnblogs.com/5aixin/p/10635980.html